Customize EditText and Button, edittextbutton
Implementation
1. edittext
Add controls to the layout
<EditText android:layout_width="150dp" android:layout_height="45dp" android:layout_gravity="center" android:layout_marginTop="20dp" android:background="@drawable/bg_edittext" android:hint="@string/request_code" android:padding="5dip" android:singleLine="true" android:textColorHint="#AAAAAA" android:textSize="15sp" />
Customize bg_edittext.xml
<? Xml version = "1.0" encoding = "UTF-8"?> <Selector xmlns: android = "http://schemas.android.com/apk/res/android"> <item android: state_window_focused = "false"> <shape android: shape = "rectangle"> <solid android: color = "@ android: color/white "/> <corners android: radius =" 10dp "/> <stroke android: width =" 2dp "android: color = "@ color/gray"/> </shape> </item> <item android: state_focused = "true"> <shape android: shape = "rectangle"> <! -- Fill in the solid --> <solid android: color = "@ android: color/white"/> <! -- Rounded corner corners corner --> <corners android: radius = "5dp"/> <! -- Stroke --> <stroke android: width = "2dp" android: color = "@ color/title_color"/> </shape> </item> </selector>
2. Button
<Button android:id="@+id/btn_make_sure" style="@style/MenuItemButtonStyle" android:layout_width="150dp" android:layout_height="45dp" android:text="@string/make_sure" android:visibility="visible" />
<! -Menu Button style --> <style name = "MenuItemButtonStyle"> <item name = "android: layout_width"> 100dp </item> <item name = "android: layout_height "> 30dp </item> <item name =" android: layout_gravity "> center </item> <item name =" android: textColor "> @ color/white </item> <item name =" android: layout_margin "> 8dp </item> <item name =" android: background "> @ drawable/slidingmenu_login_btn </item> </style>
Slidingmenu_login_btn.xml
<? Xml version = "1.0" encoding = "UTF-8"?> <Selector xmlns: android = "http://schemas.android.com/apk/res/android"> <item android: state_pressed = "true"> <shape android: shape = "rectangle"> <! -- Fill color --> <solid android: color = "@ color/violet"/> <! -- Set the four corners of the button to an arc --> <! -- Android: radius arc radius --> <corners android: bottomLeftRadius = "10dp" android: bottomRightRadius = "10dp" android: topLeftRadius = "10dp" android: topRightRadius = "10dp"/> <! -- Padding: The interval between the text in the Button and the Button boundary --> <padding android: bottom = "2dp" android: left = "2dp" android: right = "2dp" android: top = "2dp"/> </shape> </item> <shape android: shape = "rectangle"> <! -- Fill color --> <solid android: color = "@ color/title_color"/> <! -- Stroke --> <stroke android: width = "1dp" android: color = "@ color/white"/> <! -- Set the four corners of the button to an arc --> <! -- Android: radius Arc radius. Note that if the radius is greater than 10dp, you must set up the upper left corner and right corner in detail --> <corners android: bottomLeftRadius = "10dp" android: bottomRightRadius = "10dp" android: topLeftRadius = "10dp" android: topRightRadius = "10dp"/> <! -- Padding: The interval between the text in the Button and the Button boundary --> <padding android: bottom = "2dp" android: left = "2dp" android: right = "2dp" android: top = "2dp"/> </shape> </item> </selector>