Now is going to implement a custom dialog, mainly involving style file style. Refer to the case, write your own code to achieve. First create an Android Project--customdialog, and then create an XML file Filled_box.xml under the Res/drawable folder, which reads:
<?xml version= "1.0″ encoding= "Utf-8″?>
<shape xmlns:android=" http://schemas.android.com/apk/res/android "
<solid Android:color= "#ffff0000 ″/>
<stroke android:width=" 3DP "color=" #00ffff80 ″/>
<corners android: radius= "2DP"/>
<padding android:left= "10DP" android:top= "10DP"
android:right= "10DP" android:bottom= 10DP "/>
</shape>
This file mainly draws a rounded rectangle (the default value of the shape's Android:shape property is rectangle, so it is not set to a rectangle and the default is a rectangle.) ), set its fill color to #ffff0000, is solid this, the fillet size is 2DP, is corners this item, padding key controls each side to have the alignment information, the stroke item mainly is the border effect. For more information about shape, please participate in the documentation dev Guide–>framework topics–>application resources–>resource types–> Drawable the content of the page.
The next step is to create a styles.xml style file in the Res/values directory, which reads:
<?xml version= "1.0″encoding=" UTF-8″?>
<resources "
<style name=" Theme.customdialog "parent=" android:style/thEme. Dialog "
<item name=" Android:windowbackground "> @drawable/filled_box</item>
</style>
</resources>
Theme.customdialog is the name of the theme that you define, and the Parent property specifies that the theme's parental theme is Android:style/theme.dialog, which is in the theme " The dialog prompt window has been used in the case and then the window background is specified by the item named Android:windowbackground, which is previously defined by the Filled_box shape.
Now that you have a theme style definition, just add the subject item you want to use for the activity, as in the previous case, "Dialog Prompt window", Open the Androidmanifest.xml file, add the attribute android:theme= "@style/theme.customdialog" at the activity definition, and specify a theme that is a custom theme. Now you can run the project to see the effect of customization.