Skip to content

Instantly share code, notes, and snippets.

@ryancford
Created December 8, 2015 02:25
Show Gist options
  • Save ryancford/87656ef51842b3aa163a to your computer and use it in GitHub Desktop.
Save ryancford/87656ef51842b3aa163a to your computer and use it in GitHub Desktop.
Returns dimension size in pixels for a given Theme Attribute.
public static int getThemeAttributeDimensionSize(Context context, int attr)
{
TypedArray a = null;
try{
a = context.getTheme().obtainStyledAttributes(new int[] { attr });
return a.getDimensionPixelSize(0, 0);
}finally{
if(a != null){
a.recycle();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment