Przemys?aw Jakubczyk
Polidea Sp. z o.o.
Copyright (c) 2012
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the follo...
If you think the Android project AndroidImageCache listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package pl.polidea.utils;
/*www.java2s.com*/import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
/**
* @author Mateusz Grzechoci?ski <mateusz.grzechocinski@gmail.com>
*/publicclass Dimensions {
/**
* Height in pixels, by may be also {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}
* or {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
*/publicfinalint heightPX;
/**
* Width in pixels, by may be also {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}
* or {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
*/publicfinalint widthPX;
private Dimensions(int heightPX, int widthPX) {
this.heightPX = heightPX;
this.widthPX = widthPX;
}
publicstatic Dimensions fromAttributesSet(Context context, AttributeSet attributeSet) {
if (attributeSet == null) {
return null;
}
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, newint[]{R.attr.layout_width, R.attr.layout_height});
int width = typedArray.getLayoutDimension(0, 0);
int height = typedArray.getLayoutDimension(1, 0);
typedArray.recycle();
returnnew Dimensions(height, width);
}
}