2017-10-10 113 views
1

问题解决检查我的回答以下为了解通知用户照片的Android的边境使用滑翔


我想创造出正在从Facebook账户下载的资料图片的边框。但是,即使在使用计算器学习其他示例之后,我也无法正确执行此操作。正在使用Glide库下载配置文件图片。这里是我的代码: - 在XML

滑翔库代码Java中

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); 
      } 
     }); 

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"/> 

在绘制对象

<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寸手机5.5inch电话{真正的手机} enter image description here

{}仿真

enter image description here

回答

1

所以,我已经解决了这个问题,采用椭圆形我的代码是100%正确的。

我所做的是相对布局,其中我将该图像固定为90dp,这使得它不正确,只要我纠正了包装内容,它就非常适合。附上快照供其他人参考。

enter image description here

1

在您的可绘制文件上,而不是使用ova L形,将其更改为环形状,以获得一个完美的圆圈,像这样:

<shape android:shape="ring" 
xmlns:android="http://schemas.android.com/apk/res/android" > 
+0

这不是帮助 –

+0

你能告诉我环整个代码,我的环码不工作?尽管我已经将innerRadius,厚度,厚度比率和使用级别添加为false –