Android ApiDemos example resolution (4): App-& gt; Activity-& gt; Custom

Source: Internet
Author: User

The App-> Activity-> Custom Dialog example uses Activity to implement a Custom Dialog box. CustomDialogActivity has no special characteristics. The key point is its definition in AndroidManifest. xml:

<Activity android: name = ". app. CustomDialogActivity"
Android: label = "@ string/activity_custom_dialog"
Android: theme = "@ style/Theme. CustomDialog">
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. SAMPLE_CODE"/>
</Intent-filter>
</Activity>

CustomDialogActivity uses the CustomDialog style (Theme ).

Android applications can use custom Theme, which is a set of related Style definitions and can be applied to an Activity or the entire Application. One advantage of Theme is that you can define a uniform UI style (uniform background color, Font, etc.) for the entire application ).

Defining Theme is the same as defining Style. It must be defined in the/res/values subdirectory. The root element is resources. The difference between Theme and Style is that Theme is applied to Activity and Application, and Style is applied to a single View. The definition methods are consistent. Style definition supports Inheritance, that is, the new Style can be defined based on the system or previously defined Style:

For example, Theme. CustomDialog is defined as a WindowsBackground attribute that is modified only based on the Android dieme style (parent) and uses a brown background.

<Style name = "Theme. CustomDialog" parent = "android: style/Theme. Dialog">
<Item name = "android: windowBackground"> @ drawable/filled_box </item>
</Style>

 
Author: mapdigit
 

Related Article

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.