如何为Simplee Drawee Android的所有角设置半径

时间:2018-08-24 07:28:53

标签: android facebook-sdk-4.0 android-facebook

无法为Android SimpleDrawee的{​​{1}}的{​​{1}}的所有角设置半径。 我尝试过的内容:-

facebook

也尝试在xml中设置:

RoundingParams roundingParams = RoundingParams.fromCornersRadii(8f,8f,8f,8f);
            mSimpleDrawee.setHierarchy(new GenericDraweeHierarchyBuilder(getResources())
                    .setRoundingParams(roundingParams)
                    .build());

但是两者都只设置左上角半径。

5 个答案:

答案 0 :(得分:0)

在drawable下有一个rounded_corners.xml之类的drawable。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dp" android:color="@color/primary" />
<corners android:radius="25dp"/>
</shape>

然后尝试将其设置为您需要圆角的布局,例如

android:background="@drawable/rounded_corner_4"

答案 1 :(得分:0)

添加您的xml布局

android:background =“ @ drawable / round_corner”

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#FFFFFF" />

<corners android:radius="15dp" />

答案 2 :(得分:0)

在您的xml中使用此Imageview代码,希望它能正常工作

 <com.facebook.drawee.view.SimpleDraweeView
      android:id="@+id/image"
      android:layout_width="200dp"
      android:layout_height="200dp"
      android:adjustViewBounds="true"                
      fresco:roundedCornerRadius="10dp"
      fresco:roundTopLeft="true"
      fresco:roundTopRight="true"
      fresco:roundBottomLeft="true"
      fresco:roundBottomRight="true"
      fresco:roundTopStart="true"
      fresco:roundTopEnd="true"
      fresco:roundBottomStart="true"
      fresco:roundBottomEnd="true"
      />

答案 3 :(得分:0)

在构建层次结构时,可以将 RoundingParams 的实例传递给您的 GenericDraweeHierarchyBuilder

 RoundingParams roundingParams = RoundingParams.fromCornersRadius(8f);
 mSimpleDraweeView.setHierarchy(new GenericDraweeHierarchyBuilder(getResources())
    .setRoundingParams(roundingParams)
    .build());

如果要添加。 xml

<com.facebook.drawee.view.SimpleDraweeView
...
fresco:roundedCornerRadius="8dp"
fresco:roundBottomStart="false"
fresco:roundBottomEnd="false"
fresco:roundWithOverlayColor="@color/blue"
fresco:roundingBorderWidth="1dp"
fresco:roundingBorderColor="@color/red"
>

答案 4 :(得分:0)

有两个参数app:roundBottomStartapp:roundBottomEnd,您在 xml 中将两个主题都设置为true,并且所有图像上都有一个圆角

  app:roundedCornerRadius="8dp"
  app:roundBottomStart="false"
  app:roundBottomEnd="false"