Introduction to Android drawable Resource (1) and drawable Resource

Source: Internet
Author: User
Drawable Resource

A drawable resource is a common concept in plotting and can be drawn on the screen. You can retrieve it using the getdrawable (INT) method in APIs, or use it using Android: drawable, Android: icon, and other attributes in other XML resources. There are multiple types of drawable in Android.

Bitmap File: A Map File (.png, .jpg, or .gif) to generate a bitmapdrawable object.

Nine-patch file: generate a ninepatchdrawable object based on a PNG Image (.9.png) that can automatically adapt to large and small sizes.

Layer list: This drawable is used to manage one or more drawable arrays. Since it is an array, it is not difficult to understand that the element with the largest index value will be painted in the highest part. A layerdrawable object will be generated.

State List: This is an XML file used to reference different bitmap images in different States (for example, when a button control is pressed to display different images). Generate a statelistdrawable object.

Level list: an XML file that defines a drawable that can be used to manage several drawable that can be replaced. Each of them will be assigned a maximum value. A levellistdrawable will be generated.

Transition drawable: an XML file that defines a drawable that can be used for two images to form a gradient transition effect to generate a transitiondrawable object

Inset drawable: an XML file that defines a drawable and is inserted to another drawable at a specified distance. this can be used when a view <View> object requires a background image smaller than its actual border.

Clip drawable: an XML file that defines a drawable and generates a clipdrawable object based on the current aligning value for corresponding stretching.

Scale drawable: an XML file that defines a drawable and generates a scaledrawable object based on the current aligning value.

Shape drawable: defines a ry that contains color and gradient through an XML file, and generates a shapedrawable object.

Animationdrawable: You can also create an animationdrawable object.

Color drawable: in XML, a color resource <Color Resource> can also be used as a drawable. For example, when creating a State List drawable, You can reference a color resource for the Android: drawable attribute (android:drawable="@color/green")

Drawable resources are all files stored in the Res/drawable directory. Of course, in an object-oriented language, it will eventually become an object. In Android, The drawable class represents such resources. Below is the inheritance relationship between drawable and subclass.

Several common static methods in drawable can be used to create a drawable object from a file.

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.