带有SVG的圆形ImageView带填充背景

时间:2019-12-26 14:11:57

标签: android svg imageview

我正在尝试将SVG图标设置为Android ImageView的背景。 SVG图标会出现一些填充,并且颜色会有所更改。

    <ImageView
        android:id="@+id/passwordLabel"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@android:color/black"
        android:padding="30px"
        android:tint="@android:color/white"
        app:srcCompat="@drawable/ic_lock"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="524dp" />

现在有没有办法使ImageView变为圆形? 我尝试了其他解决方案,但感到困惑,因为它们要求我更改背景。

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

您不能使imageView变成圆形,因为它只是显示已经设置的图像。

  1. 改为使用CircleImageView
  2. 用CardView包裹ImageView,并使其半径为宽度/高度的一半
  3. 将您的图片形状改为圆形