Android Flat button

Source: Internet
Author: User

View

Create a Colors.xml file to define two colors

1. <resources>

2. <color name="blue_pressed"> @android: Color/holo_blue_dark </color>

3. <color name="blue_normal">@ Android:color/holo_blue_light</color>

4. </resources>

Here we use the holo tones of Android:

1. <!--A dark holo shade of blue

2. <color name="Holo_blue_dark"># ff0099cc</color>

3. <!--A light holo shade of blue

4. <color name="holo_blue_light"># Ff33b5e5</color>

Create a Dimen.xml file that defines the fillet value and the height of the shadow, see

1. <resources>

2.&NBSP;      <dimen &NBSP; name = "Corner_radius" > 4DP </DIMEN>

3. <dimen name="layer_padding"> 3dp< <dimen>

4. </resources>

We use shape to define the button background to create the Rect_pressed.xml drawable file

1. <shape xmlns:android="http://schemas.android.com/apk/res/ Android "

2. android:shape="Rectangle">

3. <corners android:radius="@dimen/corner_radius" />

4. <solid android:color="@color/blue_ Pressed " />

5. </shape>

Create a drawable file for rect_normal.xml files.

1. <layer-list xmlns:android="http://schemas.android.com/apk /res/android ">

2. <item android:drawable="@drawable/rect_pressed" />

3.

4. <item android:bottom="@dimen/layer_padding" >

5. <shape android:shape="Rectangle" C15>>

6.&NBSP;             <corners &NBSP; android:radius = " @dimen/corner_radius " &NBSP; />

7. <solid android:color="@color/blue_normal" />

8. </shape>

9. </item>

Ten. </layer-list>

Defines the selector for the button. Create a Flat_selector.xml file.

1. <selector xmlns:android="http://schemas.android.com/apk/ Res/android ">

2.&NBSP; &NBSP;&NBSP; <item &NBSP; android:state_pressed = " true " &NBSP; = "@ drawable/rect_pressed " />

3. <item android:drawable="@drawable/rect_normal" />

4. </selector>

Define the button setting background to Flat_selector.

1. <button

2. android:layout_width="Fill_parent"

3. android:layout_height="Wrap_content"

4. android:background="@drawable/flat_selector"

5. android:textcolor="@android: Color/white"

6. android:text="Say Hello" />

Android Flat button

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.