开发者

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

开发者 https://www.devze.com 2023-01-19 21:18 出处:网络
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 sett

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

精彩评论

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

关注公众号