Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. TypedValue typedValue = new TypedValue();
  2. ((Activity)context).getTheme().resolveAttribute(android.R.attr.textAppearanceLarge, typedValue, true);
  3.  
  4. int[] textSizeAttr = new int[] { android.R.attr.textSize };
  5. int indexOfAttrTextSize = 0;
  6. TypedArray a = context.obtainStyledAttributes(typedValue.data, textSizeAttr);
  7. int textSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1);
  8. a.recycle();
  9.  
  10. TypedValue typedValue = new TypedValue();
  11. ((Activity)context).getTheme().resolveAttribute(android.R.attr.textAppearanceLarge, typedValue, true);
  12.  
  13. typedValue.string
  14. typedValue.coerceToString()
  15.  
  16. typedValue.resourceId
  17. typedValue.data // (int) based on the type
  18.  
  19. <style name="TextAppearance.Large">
  20. <item name="android:textSize">22sp</item>
  21. <item name="android:textStyle">normal</item>
  22. <item name="android:textColor">?textColorPrimary</item>
  23. </style>
  24.  
  25. int[] attribute = new int[] { android.R.attr.textSize };
  26. TypedArray array = context.obtainStyledAttributes(typedValue.resourceId, attribute);
  27. int textSize = array.getDimensionPixelSize(0, -1);
  28.  
  29. final DisplayMetrics metrics = new android.util.DisplayMetrics();
  30.  
  31. WindowManager wm =(WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
  32. wm.getDefaultDisplay().getMetrics(metrics);
  33. return (int) typedValue.getDimension(metrics);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement