我正在尝试进行类似于此的对话:
但Android Developer Guide和我看到的问题都无法解决我的问题:
标题没有显示,我只是得到了我的服装布局。
我不知道如何在左边放一个“x”,在右边放一个Save-Icon!它应该适用于WINDOW FEATURES ??
对话片段代码:
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialogfragment_statsentry, container, false);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mDialog = super.onCreateDialog(savedInstanceState);
mDialog.setTitle("hello");
return mDialog;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
dialogfragment XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:minWidth="600dp"
android:layout_height="match_parent"
android:minHeight="400dp"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/dialog_statsentry_txvTime"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/dialog_statsentry_edtName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
我如何调用对话框:
StatsEntryFragmentDialog mFragment = new StatsEntryFragmentDialog();
FragmentManager mManager = getSupportFragmentManager();
if (Utils.isTablet(getApplicationContext())) {
mFragment.show(mManager, mFragment.TAG); // no fullscreen for bigger displays
}
else {
FragmentTransaction mTransaction = mManager.beginTransaction();
mTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
mTransaction.add(CONTENT_CONTAINER, mFragment).addToBackStack(mFragment.TAG).commit();
}
提前致谢!
答案 0 :(得分:2)
尝试使用Window编写对话框的高度和宽度,如下面的代码
Window window = customDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
window.setGravity(Gravity.CENTER);
customDialog.show();