Android res资源相关的方法
Android res资源相关的方法
AttributeSet attrs
属性名属性值资源id属性值的引用名类型名
AttributeSet attrs
1.属性名
android:layout_width中的”layout_width”,android:textColor中的”textColor”
String attrName =
attrs.getAttributeName(i);
2.属性值
“@1234567”
String attrValue = attrs.
getAttributeValue(i);
3.资源id
“@1234567”中的1234567
int id = Integer
.parseInt(attrValue
.substring(
1));
4.属性值的引用名
@color/red中的“red”
String entryName = context
.getResources()
.getResourceEntryName(id)
5.类型名
@color/red中的color
String typeName = context
.getResources()
.getResourceTypeName(id)
转载请注明原文地址: https://ju.6miu.com/read-963242.html