-1

I have an Android app that should show a fullscreen dialog. I've try different solution, but no one seems work. This is my code. Layout of dialog:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black_transparent" >


    <!--declaration of other widgets -->

</RelativeLayout>

this is Class that extends dialog:

publicMyDialog(Context context) {
    super(context, R.style.DialogTheme);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.setContentView(R.layout.my_dialog);
    this.setCancelable(true);
    this.setCanceledOnTouchOutside(false);
    this.getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND);

}

and this is R.style.DialogTheme declaration

<style name="DialogTheme" parent="android:Theme.Dialog">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:windowFrame">@null</item>
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowIsFloating">true</item>
</style>

Now when dialog is showed it doesn't fill all screen. How can i do for make dialog occupy all screen?

giozh
  • 9,868
  • 30
  • 102
  • 183

3 Answers3

0

There are many options for this. One is set Theme for dialog i.e.

Dialog dialog=new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);

and other is setting layout params. (You can use this in onCreateDialog() method)

 dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
Amarjit
  • 4,327
  • 2
  • 34
  • 51
0

Instead of deriving DialogTheme from parent android.Theme.Dialog, use a non dialog Theme as parent such as @android:style/Theme.Black.NoTitleBar

capt.swag
  • 10,335
  • 2
  • 41
  • 41
0

You can set

getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

Please check This for more information .I hope it will helps you .

Custom Dialog in full screen?

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198