Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- TypedValue typedValue = new TypedValue();
- ((Activity)context).getTheme().resolveAttribute(android.R.attr.textAppearanceLarge, typedValue, true);
- typedValue.string
- typedValue.coerceToString()
- typedValue.resourceId
- typedValue.data // (int) based on the type
- <style name="TextAppearance.Large">
- <item name="android:textSize">22sp</item>
- <item name="android:textStyle">normal</item>
- <item name="android:textColor">?textColorPrimary</item>
- </style>
- int[] attribute = new int[] { android.R.attr.textSize };
- TypedArray array = context.obtainStyledAttributes(typedValue.resourceId, attribute);
- int textSize = array.getDimensionPixelSize(0, -1);
- final DisplayMetrics metrics = new android.util.DisplayMetrics();
- WindowManager wm =(WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(metrics);
- return (int) typedValue.getDimension(metrics);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement