//获取控件尺寸(控件尺寸只有在事件里面可以获取到)
TextView mTV = (TextView) findViewById(R.id.iv_view);
int width = mTV.getWidth();
int height = mTV.getHeight();
//获取图片尺寸
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.about_logo);
int width2 = drawable.getIntrinsicWidth();
int height2 = drawable.getIntrinsicHeight();
//获取屏幕尺寸
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width3 = dm.widthPixels;
int height3 = dm.heightPixels;
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/pengkv/article/details/48786769