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