【问题标题】:Circular ImageView with SVG as background with padding以 SVG 为背景的圆形 ImageView 和填充
【发布时间】:2020-04-16 18:22:38
【问题描述】:

我正在尝试将 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 变成圆形吗? 我尝试了其他解决方案,但很困惑,因为他们要求我更改背景。

【问题讨论】:

    标签: android svg imageview


    【解决方案1】:

    你不能让 imageView 变成圆形,因为它只是显示了已经设置好的图像。

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

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-12
        • 2019-01-28
        • 2016-08-02
        • 1970-01-01
        相关资源
        最近更新 更多