How to remove border from Dialog?

后端 未结 5 1500
太阳男子
太阳男子 2020-12-04 19:59

I have an activity which is shown in a dialog:

\"\"

In order to remove border and rounded corners, i tr

5条回答
  •  抹茶落季
    2020-12-04 20:44

    The border, round corners and margin are all defined by android:windowBackground. (Parameter android:windowFrame is already set to @null in Theme.Dialog style, therefore setting it to @null again has no effect.)

    In order to remove the border and round corners you have to change the android:windowBackground appropriately. The Theme.Dialog style sets it to @android:drawable/panel_background. Which is a 9-patch drawable that looks like this (this one is the hdpi version):

    enter image description here

    As you can see the 9-patch png defines the margin, border and round corners of the dialog theme. To remove the border and round corners you have to create an appropriate drawable. If you want to keep the shadow gradient you have to create set of new 9-patch drawables (one drawable for each dpi). If you don't need the shadow gradient you can create a shape drawable.

    The required style is then:

    
    

提交回复
热议问题