How to use system resources in Android development tutorial Android resource file

1、 Color resource 1. Color XML file format

2. Reference format:

In Java code: r.color.color_ Name (this is an int type data used to represent the address of the resource) in the XML file: @ color / color_ name

3. The method to obtain the color value is getresources(). Getcolor(); Returns a color value similar to #0000ff. 2. String resource

1. XML file format

Note that in the control, settext (int resid) and settext (string_name) are allowed. 3. Size resources

1. XML file:

The unit of size value can be PX (pixel) or mm (mm, actual screen size) or DP

2. Reference format java code: r.dimension.dimension_ Name in XML file: @ dimension / dimension_ name 3、Resources.getDimension(R.dimen.dimen_name); Note that the value returned by this method is a float type value, and the setwidth () parameter is generally required to be of type int, so a forced type conversion is required. 4、 XML resource file

1. XML file: the XML file of Android program is generally placed in values / XML / XML_ At name.xml, you need to use new - > file to create a new XML file; The version of the XML file

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>