Android Simple Development Tutorial 18: Customizing dialog box transform

Source: Internet
Author: User

Android's own alertdialog,progressdialog,datepickerdialog,timepickerdialog can be used for simple dialog box display. You can use some custom dialog boxes when you still have these dialog boxes that don't meet your application's needs. There are several ways to implement a custom dialog box. One is the use of activity as a dialog, can be set by the activity Display dialog style, so that the activity in appearance and dialog consistent: shown in front of other activity and translucent.

<activity android:name= "mydialogactivity" android:theme= "@android: Style/theme.dialog " ></ Activity>

This example uses the other two methods to use the custom dialog box, which will use this dialog box to most graphically transform (Transform) options:

Primitive:rectange, Ellipse,text pen:thin,thick,dashed brush:solid, Gradient,texture transform:identity, Rotate, Scal E, Shear Rendering:stroke, fill, Stoke and fill

First, under Res/layout, create a new Transformoption.xml as a custom dialog box layout:

<?xml version= "1.0″encoding=" utf-8″?>
<linearlayout
Xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
>
<scrollview
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent" >
<linearlayout
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:orientation= "Vertical"
>
<textview
android:text= "Primitive"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</TextView>
<radiogroup
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<radiobutton
android:text= "Rectangle"
Android:id= "@+id/radiorectangle"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Ellipse"
Android:id= "@+id/radioellipse"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Text"
Android:id= "@+id/radiotext"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
</RadioGroup>
<textview
android:text= "Pen"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</TextView>
<radiogroup
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<radiobutton
android:text= "Thin"
Android:id= "@+id/radiothin"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "thick"
Android:id= "@+id/radiothick"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Dashed"
Android:id= "@+id/radiodashed"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
</RadioGroup>
<textview
android:text= "Brush"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</TextView>
<radiogroup
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<radiobutton
android:text= "Solid"
Android:id= "@+id/radiosolid"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Gradient"
Android:id= "@+id/radiogradient"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Texture"
Android:id= "@+id/radiotexture"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
</RadioGroup>
<textview
android:text= "Transform"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</TextView>
<radiogroup
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<radiobutton
android:text= "Identity"
Android:id= "@+id/radioidentity"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Rotate"
Android:id= "@+id/radiorotate"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Scale"
Android:id= "@+id/radioscale"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Shear"
Android:id= "@+id/radioshear"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
</RadioGroup>
<textview
android:text= "Rendering"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</TextView>
<radiogroup
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<radiobutton
android:text= "Stroke"
Android:id= "@+id/radiostroke"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
android:text= "Fill"
Android:id= "@+id/radiofill"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
<radiobutton
Android:text= "Stroke and Fill"
Android:id= "@+id/radiostrokefill"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</RadioButton>
</RadioGroup>
</LinearLayout>
</ScrollView>
</LinearLayout>

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.