Created
January 15, 2015 06:48
-
-
Save xxxzhi/9872b8d53fa935a64e36 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/7896615/android-how-to-get-value-of-an-attribute-in-code using java to get attribute。
用java 代码去获取属性的值。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypedValue typedValue = new TypedValue(); | |
// ((Activity)context).getTheme().resolveAttribute(android.R.attr.textAppearanceLarge, typedValue, true); | |
int[] textSizeAttr = new int[] { android.R.attr.textSize }; | |
int indexOfAttrTextSize = 0; | |
TypedArray a = context.obtainStyledAttributes(typedValue.data, textSizeAttr); | |
int textSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1); | |
a.recycle(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment