Android-dialog Style activity Development

Source: Internet
Author: User

1. Set the window style:

① Set the Theme property Android:theme= "@android: Style/theme.dialog" in Manifest, or Theme.Holo.Dialog.

② is set in the activity's OnCreate method and must be called Settheme (Android) before Setcontentview. R.style.theme_holo_dialog)

The use of Theme.Holo.Dialog for Android 4.X style, the effect is better, and theme.dialog style is 2.X style, more outdated.

2. Set layout properties:

In the process of adjusting the interface, it is found that the dialog style activity and Alertdialog interface effect is quite different, mainly because Alertdialog uses attributes.

For example:

Button style: style= "? Android:attr/buttonbarbuttonstyle"

button outer layout style: style= "? Android:attr/buttonbarstyle"

Horizontal Split Line: android:background= "? Android:attr/dividerhorizontal"

Content font Size: android:textappearance= "? Android:attr/textappearancemedium"

The following is a sample example:

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:gravity= "Center_horizontal"android:orientation= "vertical" >    <TextViewAndroid:id= "@+id/live_wallpaper_dialog_content"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_marginbottom= "5DP"Android:layout_margintop= "5DP"android:gravity= "Center_vertical|center_horizontal"Android:text= "This is Content"android:textappearance= "? Android:attr/textappearancemedium" />    <ViewAndroid:layout_width= "Match_parent"Android:layout_height= "1DP"Android:background= "? Android:attr/dividerhorizontal" />    <LinearLayoutstyle= "? Android:attr/buttonbarstyle"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:measurewithlargestchild= "true" >        <ButtonAndroid:id= "@+id/live_wallpaper_dialog_cancel"style= "? Android:attr/buttonbarbuttonstyle"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_weight= "1"Android:text= "Cancel" />        <ButtonAndroid:id= "@+id/live_wallpaper_dialog_download"style= "? Android:attr/buttonbarbuttonstyle"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_weight= "1"Android:text= "Download" />    </LinearLayout></LinearLayout>

3. How to set the click Space without exiting activity:

Alertdialog? is set Setcanceledontouchoutside (false) to implement.

The activity is achieved by setting Setfinishontouchoutside (false).

Android-dialog Style activity Development

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.