Customize EditText and Button, edittextbutton

Source: Internet
Author: User

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>

Related Article

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.