+-
使用Glide的圆形轮廓图片的Android边框
问题已解决请在下面检查我的答案以了解

我正在尝试创建从Facebook帐户下载的个人资料图片的边框.但是即使在stackoverflow研究了其他示例之后,我也无法正确执行此操作.正在使用Glide库下载个人资料图片.这是我的代码:-

Java中的Glide库代码

Glide.with(Home.this).load(url).asBitmap().into(new BitmapImageViewTarget(profile_pic){
            @Override
            protected void setResource(Bitmap resource) {
                RoundedBitmapDrawable circular = RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(),resource);
                circular.setCircular(true);
                profile_pic.setImageDrawable(circular);
            }
        });

XML中的ImageView

<ImageView
        android:id="@+id/profile_pic"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@mipmap/ic_launcher"
        android:padding = "5dp"
        android:background="@drawable/profile_pic_border"/>

Drawable中的绘图边框

<shape android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
    android:width="5dp"
    android:color="#3e65b4"/>
<size android:height="50dp"
android:width="50dp"/>

这是我从上述代码中实现的目标:-

在5.7英寸手机{Real Phone}中
enter image description here

在5.5英寸手机中{仿真器}

enter image description here

最佳答案
因此,我已经解决了这个问题,我的代码使用椭圆形是100%正确的.

我所做的是在相对布局中,我将该图像固定为90dp,这使其变得不合适,当我更正要包装的内容时,它就非常合适.随附快照,供其他人参考.

enter image description here

点击查看更多相关文章

转载注明原文:使用Glide的圆形轮廓图片的Android边框 - 乐贴网