开发者

How to change the size of a bitmap contained in an ImageView without affecting surrounding view's position in Android?

I have an ImageView that contain开发者_如何学编程s a bitmap. Now the bitmap can change size within a known range. This makes the surrounding views to relocate which I want to prevent. I've tried setting margins and padding for the ImageView but without success. Any ideas? Thanks, Christian


Try putting your ImageView and other UI elements into a FrameLayout and setting each item's android:layout_gravity to place them.


Try this:

imageView = new ImageView(context)
{
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
     {
         setMeasuredDimension(knownMaxWidth, knownMaxHeight);

     }
};

imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜