Remove Android Custom dialog black background, set no border, transparent

Source: Internet
Author: User

When we customize dialog, we tend to want to remove the Android system definition background and title, so that we can better display our own desired effect.

In fact, we just need to pay attention to a few places on the line.

1. Define the theme of dialog in the style file

  1. <style name="Mydialog">
  2. <item name="Android:windowframe"> @null</Item>
  3. <item name="Android:windowbackground"> @android: color/transparent</ Item>
  4. <item name="Android:windownotitle">true</Item>
  5. <item name="android:windowisfloating">true</Item>
  6. <item name="Android:windowcontentoverlay"> @null</Item>
  7. </style>

The main thing is this: <item name= "Android:windowbackground" > @android:color/transparent</item> set Windowbackground to Transparent

2. Used in the custom dialog construction method, if you use this theme in the dialog layout file is not useful, you must use this theme in all three construction methods, so that you do not have to invoke the theme when you enter which constructor method. Otherwise you will not see the effect.

Public Mydialog (Context context) {

Super (Context,r.stytle.mydialog);

}

Public Mydialog (Context context,int thremid) {

Super (Context,r.stytle.mydialog);

}

So your dialog should be able to show no black background and no border.

Remove Android Custom dialog black background, set no border, transparent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.