Source code 👉 github.com/javakam/Dia…

DialogInvalid rounded corners

The same is setBackgroundDrawableResource or setBackgroundDrawable invalid problem; There are two types of Dialog, one is a titled Dialog and the other is an untitled Dialog

why

Dialog setting background essentially uses dialog. setContentView method, and the Android system provides Dialog itself with the layout space of the title, when the title is hidden through the Window setting, Rounded under no heading is rounded for the rest of the FrameLayout so it’s easy to understand.

controlDialogThe way the title is hidden

requestWindowFeature(Window.FEATURE_NO_TITLE)

or

<style name="AndoDialog">
        <item name="android:windowNoTitle">false</item><! --false with title true without title -->
</style>
Copy the code

Have a title

Direct Settings window. SetBackgroundDrawableResource (R.d rawable. Rectangle_ando_dialog_bottom), some blog is not saying the following configuration:

It's no use / /
window.setBackgroundDrawableResource(android.R.color.transparent)
window.decorView.setPadding(0.0.0.0)
Copy the code

There are captioned renderings

No title

To handle rounded corners without a title is to make rounded corners for FrameLayout

When no title window. SetBackgroundDrawableResource (R.d rawable. Rectangle_ando_dialog_bottom) Settings take effect, need to adjust the layout file Dialog. If the top left and top right corner of the bottom popover are rounded, set the rounded background and add paddingXXX property to the same value as android:xxxRadius=”10dp” in Drawable.

PaddingTop ="10" Android :background="@drawable/rectangle_ando_dialog_bottom"Copy the code

No titled renderings

You can see a part of the white gap at the top

The attached

rectangle_ando_dialog_bottom.xml


      
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />

    <solid android:color="@color/color_ando_dialog_white" />
</shape>
Copy the code

Source code 👉 github.com/javakam/Dia…