API-TypedArray
16lz
2021-12-04
TypedArray | Android Developers
https://developer.android.google.cn/reference/android/content/res/TypedArray.html
简介:Container for an array of values that were retrieved with obtainStyledAttributes(AttributeSet, int[], int, int) or obtainAttributes(AttributeSet, int[]). Be sure to call recycle() when done with them. The indices used to retrieve values from this structure correspond to the positions of the attributes given to obtainStyledAttributes.
翻译过来就是:
- 一个用来检索属性值的容器;
- 使用完之后,必须recycle();
- index下标用来检索属性,相当于属性在obtainStyledAttributes(获取样式属性)中的position.
再来看方法:
返回值 | 方法名 |
---|---|
boolean | getBoolean(int index, boolean defValue) |
int | getColor(int index, int defValue) |
float | getDimension(int index, float defValue) |
Drawable | getDrawable(int index) |
float | getFloat(int index, float defValue) |
int | getInt(int index, int defValue) |
int | getInteger(int index, int defValue) |
String | getString(int index) |
CharSequence | getText(int index) |
其他方法:
返回值 | 方法名 | 解释 |
---|---|---|
ColorStateList | getColorStateList(int index) | |
int | getDimensionPixelOffset(int index, int defValue) | |
int | getDimensionPixelSize(int index, int defValue) | |
float | getFraction(int index, int base, int pbase, float defValue) | |
int | getIndex(int at) | |
int | getIndexCount() | |
int | getLayoutDimension(int index, int defValue) | |
int | getLayoutDimension(int index, String name) | |
String | getNonResourceString(int index) | |
String | getPositionDescription() | |
int | getResourceId(int index, int defValue) | |
Resources | getResources() | |
CharSequence[] g | etTextArray(int index) | |
boolean | getValue(int index, TypedValue outValue) | |
boolean | hasValue(int index) | |
int | length() | |
TypedValue | peekValue(int index) | |
void | recycle() |
更多相关文章
- ImageView
- android 拖动条改变屏幕亮度
- Android(安卓)WebView相关属性
- Android图片按比例缩放
- android:duplicateParentState="true"
- android:windowSoftInputMode属性使用
- Android(安卓)系统图标
- android:windowSoftInputMode属性使用
- Android中的AnimationSet使用