问题描述
我有一个带有 EditText 的示例对话框片段。它始终在设备屏幕顶部显示光标气泡。但对话框出现在中心。我尝试更改活动主题并尝试自定义对话框,但没有解决问题。谁能帮我解决这个问题。
public class SampleAlertDialog extends DialogFragment {
public static SampleAlertDialog getInstance() {
SampleAlertDialog dialog = new SampleAlertDialog();
return dialog;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.layout_dialog,null))
// Add action buttons
.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int id) {
// sign in the user ...
}
})
.setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.dismiss();
}
});
return builder.create();
}
}
对话框的 XML 文件是
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_dialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</android.support.constraint.ConstraintLayout>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)