I want to get width and height of ImageView.
myimgbg = (ImageView) findViewById(R.id.myimggb); myimgbg.setBackgroundResource(R.drawable.dudu_1); I want to get width and height of ImageView.
myimgbg = (ImageView) findViewById(R.id.myimggb); myimgbg.setBackgroundResource(R.drawable.dudu_1); The other answers demonstrate how to get the dimensions, but you are trying to do it too early, before the layout has been measured. This is how you do this but I am pretty sure you should never need to do this - there is almost always a better way that does not require you to know the pixel dimensions of anything.
myimgbg.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { myimgbg.getViewTreeObserver().removeGlobalOnLayoutListener(this); int width = myimgbg.getWidth(); } }); Just to emphasize again, if you are doing something that requires knowing the exact pixel size of a view, you should probably take a step back and reconsider how to do what you want.
int width; myimgbg.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { myimgbg.getViewTreeObserver().removeGlobalOnLayoutListener(this); width = myimgbg.getWidth(); } }); Log.e("with",with+""); Just try, after your view is drawn
yourView.getHeight() yourView.getWidth() or
LayoutParams params=yourView.getLayoutParams(); params.height //is your views height