-1

I am running my android app in my android phone which is OS 8.1 Oreo and it seems no problem with the dialogue, but when i install/build to other phone which is android lollipop the dialogue deform to its original size.

See image below.

Please click for the image (Error design deform)

Source code on dialogue

 final Dialog dialog = new Dialog(context);
        dialog.setContentView(R.layout.dialogue_dash_date_picker);

        final Spinner spinner = dialog.findViewById(R.id.typeViewSpinner);
        Button btnDismiss = dialog.findViewById(R.id.btnOK);
        String viewType = ViewTypeSingleton.getInstance().getTypeview();
        if (viewType.equals(""))
            spinner.setSelection(0);
        else if (viewType.equals("Day"))
            spinner.setSelection(1);
        else if (viewType.equals("Week"))
            spinner.setSelection(2);
        else if (viewType.equals("Month"))
            spinner.setSelection(3);
        else if (viewType.equals("Year"))
            spinner.setSelection(4);
        else if (viewType.equals("All"))
            spinner.setSelection(5);

        btnDismiss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                String choosen = spinner.getSelectedItem().toString();
                ViewTypeSingleton.getInstance().setTypeview(choosen);
                message.success(""+choosen,context);
                fragmentRedirection(new fragment_main());
            }
        });
        dialog.create();
        dialog.show();

Please help me fix this one.

Thanks

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

0

Add this style into your style.xml

<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog">

    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>

</style>

And Create your dialog like this

 final Dialog dialog = new Dialog(context, R.style.MyDialogTheme);
Radesh
  • 13,084
  • 4
  • 51
  • 64
0

Please try by setting height and width of dialog using below way:

Dialog dialog = new Dialog(context,android.R.style.Theme_Translucent_NoTitleBar);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.YOUR_LAYOUT);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity = Gravity.CENTER;
dialog.getWindow().setAttributes(lp);
dialog.show();
Mohit Dholakia
  • 252
  • 2
  • 16
  • Thank you for the help @Mohit Dholakia but still it problem on its display only in center left side, the best answer is the above line i just added on the style.xml Anyways thanks for the time solving my problem :) – Hard Harry Nadela Feb 13 '19 at 14:12