Customize IOS buttons in Android

Source: Internet
Author: User

IOS-style UIS are popular. Many Android UI designers are also willing to design Android UI into a UI style similar to IOS. The following is an example to illustrate how to use Shape to define an IOS-style button.

 

Define an ios_button_grouped.xml file.

<? Xmlversion = "1.0" encoding = "UTF-8"?>

<Selector

Xmlns: android = "http://schemas.android.com/apk/res/android">

<Item

Android: state_pressed = "true"

Android: drawable = "@ drawable/ios_button_grouped_pressed"/>

<Item

Android: state_focused = "true"

Android: state_window_focused = "true"

Android: drawable = "@ drawable/ios_button_grouped_pressed"/>

<Item

Android: drawable = "@ drawable/ios_button_grouped_normal"/>

</Selector>

 

 

Define ios_button_grouped_normal.xml

<? Xmlversion = "1.0" encoding = "UTF-8"?>

<Shape

Xmlns: android = "http://schemas.android.com/apk/res/android"

Android: shape = "rectangle">

<Solid

Android: color = "# eee"/>

<Stroke

Android: width = "1dp"

Android: color = "@ android: color/black"/>

<Corners

Android: radius = "5dp"/>

</Shape>

 

Define ios_button_grouped_pressed.xml

<? Xmlversion = "1.0" encoding = "UTF-8"?>

<Shape

Xmlns: android = "http://schemas.android.com/apk/res/android"

Android: shape = "rectangle">

<Solid

Android: color = "# 0be"/>

<Stroke

Android: width = "1dp"

Android: color = "@ android: color/black"/>

<Corners

Android: radius = "5dp"/>

</Shape>

 

Here we mainly define the color of the rectangle in the Shape. You can also set some color attributes, such as startColor, endColor, and angle, to define beautiful UI effects. We recommend that you refer to the API documentation.

 

Effect:




 

Usage:

Use the image as the background.

Android: background = "@ drawable/ios_button_grouped"

 

---------------------------------------------------------------------------

GL (arui319)

Http://blog.csdn.net/arui319

 

Excerpted from chinamoocs

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.