我試圖讓機器人的ImageView的高度&寬度它返回0如何獲取ImageView的高度和寬度?
public class FullScreenImage extends FragmentActivity {
ImageView full_view;
int width;
int height;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.full_screen);
full_view = (ImageView)findViewById(R.id.full_view);
Bundle bundle=getIntent().getExtras();
byte[] image= bundle.getByteArray("image");
width = full_view.getWidth();
height = full_view.getHeight();
Bitmap theImage = BitmapFactory.decodeByteArray(image, 0, image.length);
Bitmap resized = Bitmap.createScaledBitmap(theImage,width , height, true);
full_view.setImageBitmap(resized);
}
}
請大家幫幫我,我該怎麼做呢?
除到Farhan已經提到的你也可以看一下'http:// developer.android.com/reference/android/view/ViewTreeObserver.OnGlobalLayoutListener.html' – Anuj