My Android Advanced tour------> How do I turn activity into a translucent dialog box?

Source: Internet
Author: User



My Android Advanced tour------> How do I turn activity into a translucent dialog box? Can be considered from two aspects: dialog box and translucent.

Specifying the Theme.dialog theme when you define an activity enables you to set activity as a dialog style.

You can change the background image of an activity by altering the Android:windowbackground property value of the Theme.dialog theme.

Assuming the background image uses a translucent image, the activity becomes a translucent dialog box. In order to change the Android:windowbackground property, it is possible to define a new theme that inherits from the Theme.dialog code, such as the following:

Create two XML files under Res/values. One for theme style resources Dialog_styles.xml.

One for the color resource dialog_colors.xml.


Dialog_styles.xml, themed style named Dialog_translucent

<?xml version= "1.0" encoding= "Utf-8"?

><resources> <style name= "dialog_translucent" parent= "@android: Style/theme.dialog" > < Item Name= "Android:windowbackground" > @color/translucent_background</item> <item name= "Android: Windowistranslucent ">true</item> <item name=" Android:windownotitle ">true</item> <item name= "Android:windowanimationstyle" > @android: Style/animation.translucent</item<span style= " White-space:pre "></span>> </style></resources>

Dialog_colors.xml

<?xml version= "1.0" encoding= "Utf-8"?><resources> <color    name = "Translucent_background" ># 00000000</color></resources>

Specify the topic you define for activity in Androidmanifest.xml,Android:theme= "@style/dialog_translucent"

The code is as follows:

       <activity            android:name= ". Dialogactivity "            android:configchanges=" orientation|keyboardhidden|screensize "            android:label=" @string/ App_name "            android:theme=" @style/dialog_translucent "><!--reference your own defined theme-->>            <intent-filter >                <action android:name= "Android.intent.action.MAIN"/>                <category android:name= " Android.intent.category.LAUNCHER "/>            </intent-filter>        </activity>



==================================================================================================

Ouyangpeng welcome reprint, sharing with people is the source of progress!

Reprint please keep the original address : Http://blog.csdn.net/ouyang_peng

==================================================================================================

  

My Android Advanced tour------&gt; How do I turn activity into a translucent dialog box?

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.