滑动圆形图像被裁剪

问题描述 投票:1回答:2

我正在尝试使用滑行制作圆形图像...我按照本教程How to round an image with Glide library?但我的图像总是得到顶部和底部裁剪

enter image description here

我试图改变图像视图尺寸,但没有任何变化,总是裁剪和相同的比例

我究竟做错了什么

Glide.with(this).load(MasterFacade.getFacade().getLocalUser().getProfilePicUrl()).apply(RequestOptions.centerCropTransform()).into((ImageView) findViewById(R.id.profileImageView));

和布局

<ImageView
                android:id="@+id/profileImageView"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center"
                android:scaleType="fitXY" />
android imageview android-glide rounded-corners
2个回答
1
投票
<ImageView
                android:id="@+id/profileImageView"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center"
                android:layout_margin="15dp"
                android:scaleType="fitXY" />

问题是与其他视图重叠,边缘应该可以解决您的问题


0
投票

试试这个

添加xml布局:

         <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="1dp"
                    android:id="@+id/lay_profpic"
                    android:layout_gravity="center"
                    android:layout_margin="20dp"
                    android:background="@drawable/border_circle">

                    <ImageView
                         android:id="@+id/profile_picture"
                         android:scaleType="centerCrop"
                         android:layout_centerHorizontal="true"
                         android:src="@color/white"
                         android:layout_gravity="center"
                         android:layout_width="90"
                         android:layout_height="90dp" />
                </RelativeLayout>

使用Glide添加Java代码

Glide.with(this)
                .load(user.getProfilePicture())
                .transform(new CircleTransform(this))
                .into(new GlideDrawableImageViewTarget(ivProfilePicture) {
                    @Override
                    public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
                        super.onResourceReady(drawable, anim);
                        ivProfilePicture.setImageDrawable(drawable);
                        ivProfilePicture.invalidate();
                        ivProfilePicture.requestLayout();
                    }
                });
© www.soinside.com 2019 - 2024. All rights reserved.