Saturday, 7 September 2013

Android Activity drawable size

Android Activity drawable size


There are many question if you search. The answers are telling the screen
width / height. NOT that needed!
I need the available space for the image view: the car with white
background. How to get it?
I don't need the top decoration bar, neither the bottom / right menu bar
neither the whole screen size wich include the time, battery.
Here is what I have tried so far:
public class MainActivity extends Activity {
private SVGImageView svgImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
svgImageView = new SVGImageView(this);
svgImageView.setImageAsset("my.svg");
// Set the ImageView as the content view for the Activity
setContentView(svgImageView);
}
@Override
protected void onPostResume() {
super.onPostResume();
int w = getWindow().getDecorView().getWidth();
int h = getWindow().getDecorView().getHeight();
Log.d("DisplayMetrics","w2:"+w+", h2:"+h);// 0 and 0
}
@Override
protected void onStart() {
super.onStart();
DisplayMetrics metrics = getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
//int bottom = svgImageView.getBottom();
int w = svgImageView.getWidth();//0
int h = svgImageView.getHeight();//0
Log.d("DisplayMetrics", "width: "+width+ ", height:"+height+",
w:"+w+", h:"+h);
// landscape: 1280 x 752. Real 1280x700
// portrait: 800 x 1232. Real 800x1177
}
SVGImageView is a child of ImageView more about SVG Here if anyone
interested.

No comments:

Post a Comment