如何从imageview或位图获取宽度和高度?

时间:2014-11-21 21:15:29

标签: android bitmap android-imageview android-drawable

我在google,stackoverflow上搜索了很多,...

我发现并尝试了所有这些:

Bitmap b = ((BitmapDrawable)imageView.getBackground()).getBitmap();
int w = b.getWidth();
int h = b.getHeight();

imageView.setDrawingCacheEnabled(true);
Bitmap b = imageView.getDrawingCache();
int w = b.getWidth();
int h = b.getHeight();

imageView.getWidth(); 
imageView.getHeight(); 

Drawable d = getResources().getDrawable(R.drawable.yourimage);
int h = d.getIntrinsicHeight(); 
int w = d.getIntrinsicWidth();

但每种方法都会产生相同的结果。我可以在横向模式和肖像模式下拍照。每次宽度为1024 高度为768 但我等人像模式高度必须 1024 宽度必须是768

请有人帮助我。

0 个答案:

没有答案