我试图获得图像视图中显示的图像的实际大小.实际上我的图像比屏幕大,图像视图正在调整图像大小以显示它.我正在寻找这个新尺寸.
我试图在自定义视图中覆盖ImageView的onDraw方法,但我没有得到正确的高度和宽度...
public class LandImageView extends ImageView
{
public LandImageView( Context context )
{
super( context );
}
public LandImageView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public LandImageView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
@Override
protected void onDraw( Canvas canvas )
{
super.onDraw( canvas );
int test = this.getWidth();
int test2 = this.getHeight();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
}
}
Run Code Online (Sandbox Code Playgroud)
你有线索吗?