0

I'm trying to make an dialog similar to this one:

Costum full screen dialog example

But the neither the Android Developer Guide nor the questions I saw can solve my problems:

  1. The title isn't displayed, I just get my costum layout.

  2. I do not know how to put an "x" on the left and a Save-Icon on the right side! Should it work with WINDOW FEATURES??

The dialogfragment code:

@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);
}

The 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>

And how I call the dialog:

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();
}

Thanks in advance!

the_dani
  • 2,466
  • 2
  • 20
  • 46

1 Answers1

2

try this set hight and width of your dialog programatically using Window like below code

Window window = customDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
window.setGravity(Gravity.CENTER);
customDialog.show();
AskNilesh
  • 67,701
  • 16
  • 123
  • 163