I have an android activity that implements a custom dialog.The application is running ok but the dialog is too small,i want to display a bigger dialog.How can i achieve this
Setting android:minWidth and android:minHeight in the custom layout does the trick for me.
You can add tag below
<Space
android:layout_width="600dp"
android:layout_height="1dp"/>
inside your parent layout , so dilog layout fill the width of screen as much as poossible.
NOTICE android:layout_width="600dp"
value should be more than screen witdth ,
and I think 600dp is enough for MobileScreens.
<style name="full_screen_dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:minWidth" type="dimen">600dp</item>
</style>
Use this in style.xml
file and use this style in dialog class
Change your dialog dimension on runtime:
yourDialog.show();
yourDialog.getWindow().setLayout((6 * width)/7, LayoutParams.WRAP_CONTENT);
You can do that for both dimension, in my example i only changed the width. Hope it helps!
EDIT
I forgot to mention where i took width:
DisplayMetrics metrics = getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
EDIT 2
Try this code:
Dialog yourDialog = dialogFragment.getDialog();
yourDialog.getWindow().setLayout((6 * width)/7, (4 * height)/5);
put below line in onCreate
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth);
original answer
The right solution is to override the onCreateDialog
method rather than onCreateView
, and create your dialog with a AlertDialog.Builder
, as explained in the doc: http://developer.android.com/reference/android/app/DialogFragment.html#AlertDialog