Common methods of Android UI

Source: Internet
Author: User

1. Control drag

Select the control from the Right Palette menu bar and drag to the left layout

2. layout file reuse Include Other layout ...

Create Bar_layout.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent" >

<imageview
Android:id= "@+id/imageview1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignparentleft= "true"
Android:layout_alignparenttop= "true"
android:src= "@drawable/lrc_screen_light_on"/>

<textview
Android:id= "@+id/textview1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignbottom= "@+id/imageview1"
Android:layout_centerhorizontal= "true"
Android:text= "Light ..."
Android:textappearance= "? Android:attr/textappearancelarge"/>

<imageview
Android:id= "@+id/imageview2"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignparentright= "true"
Android:layout_alignparenttop= "true"
android:src= "@drawable/lrc_screen_light_on"/>

</RelativeLayout>

Reuse in Main_layout.xml

<include
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignparentleft= "true"
Android:layout_alignparenttop= "true"
layout= "@layout/bar_layout"/>

3. Control background Definition drwable file

Create shape_backgroud.xml under the Drwable directory

<?xml version= "1.0" encoding= "Utf-8"?>

<shape xmlns:android= "Http://schemas.android.com/apk/res/android" >
<gradient
Android:startcolor= "#333300"
Android:endcolor= "#ffff00"
Android:angle= "90"
/>
</shape>

Using in controls

android:background= "@drawable/shape_backgroud"

4.style style definition

Create a new stype_checkbox.xml in the Drawable folder

<?xml version= "1.0" encoding= "Utf-8"?>
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:drawable= "@drawable/icon_checkbox_normal" android:state_checked= "false" ></item>
<item android:drawable= "@drawable/icon_checkbox_checked" android:state_checked= "true" ></item>
<item android:drawable= "@drawable/icon_checkbox_normal" ></item>
</selector>

Add in Style.xml <resourse> in the Values folder

<style name= "Logincheckboxtheme" parent= "@android: Style/widget.compoundbutton.checkbox" >
<item name= "Android:button" > @drawable/stype_checkbox</item>
</style>

Using in controls

style= "@style/logincheckboxtheme"

CheckBox turns into circle by box

5. Progress bar

Create a new stype_progressbar.xml in the Drawable folder

<?xml version= "1.0" encoding= "Utf-8"?>

<!--rotation progress

<animated-rotate

Xmlns:android= "Http://schemas.android.com/apk/res/android"
android:drawable= "@drawable/loading"
android:pivotx= "50%"
Android:pivoty= "50%"
/>

-

<!--level Progress

<layer-list xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:id= "@android: Id/background" >
<shape>

<corners android:radius= "5dip"/>
<gradient android:startcolor= "#333300"
Android:endcolor= "#666600"
Android:angle= "90"
/>
</shape>
</item>
<item android:id= "@android: Id/progress" >
<clip>
<shape>
<corners android:radius= "3dip"/>
<gradient android:startcolor= "#666600"
Android:endcolor= "#999900"
Android:angle= "/>"
</shape>
</clip>
</item>
</layer-list>

-

Using in the <ProgressBar> control

android:indeterminatedrawable= "@drawable/shape_backgroud"

Common methods of Android UI

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.