Summary of the drawable of Android-resource

Source: Internet
Author: User

This article directly and selectively translates the official development guide

=============================

There are 10 types of drawable, as follows

-Bitmap file: This is simple, you can also use XML to define more detailed, first press do not write ....

-Nine-patch File: This is a custom bloom area of the bitmap, generally with. 9.png suffix, may be generated with sdk/tools/draw9patch.bat, in fact, the tool in the outer edge of the picture to add a one-pixel border to mark " Zoom area ", as follows

    

After adjusting, you will get this effect:

    

-Layer List: A multi-level drawable that is drawn to the screen sequentially:

<?XML version= "1.0" encoding= "Utf-8"?><layer-listxmlns:android= "Http://schemas.android.com/apk/res/android">    <Item>      <Bitmapandroid:src= "@drawable/android_red"android:gravity= "Center" />    </Item>    <ItemAndroid:top= "10DP"Android:left= "10DP">      <Bitmapandroid:src= "@drawable/android_green"android:gravity= "Center" />    </Item>    <ItemAndroid:top= "20DP"Android:left= "20DP">      <Bitmapandroid:src= "@drawable/android_blue"android:gravity= "Center" />    </Item></layer-list>

The effect is as follows:

-State List: is based on the status of the drawable to determine which drawable to display, such as a button has (pressed, focused, niether) various states.

Examples are as follows:

<?XML version= "1.0" encoding= "Utf-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android">    <Itemandroid:state_pressed= "true"android:drawable= "@drawable/button_pressed" /> <!--pressed -    <Itemandroid:state_focused= "true"android:drawable= "@drawable/button_focused" /> <!--focused -    <Itemandroid:state_hovered= "true"android:drawable= "@drawable/button_focused" /> <!--hovered -    <Itemandroid:drawable= "@drawable/button_normal" /> <!--default -</selector>

Summary of the drawable of Android-resource

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.