当重写ImageView的时候需要获取android:src的值
可以通过:getAttributeResourceValue("http://schemas.android.com/apk/res/android","src",0);获取
如果是自定义的属性,比如bitmap
通过:getAttributeResourceValue(null,"bitmap",0);
int android.util.AttributeSet.getAttributeResourceValue(String namespace, String attribute, int defaultValue) 方法
参数:
namespace: 属性的位置,android内置属性的默认位置在http://schemas.android.com/apk/res/android,自定义属性的就直接null就好
attribute: 属性的名字
defaultValue: 如果找不到该属性的话,返回啥
【技巧】获取android xml文件中控件的属性的值
原文:http://www.cnblogs.com/kirno/p/3995689.html