【问题标题】:Custom ImageView shape drawable in xml like this one in android自定义 ImageView 形状可在 xml 中绘制,如 android 中的这个
【发布时间】:2016-05-16 08:45:41
【问题描述】:

我想创建一个像这样的 ImageView。我知道它是矩形和三角形的组合,

but I really don't know how to implement it.

XML 有可能吗?在这种情况下,图层列表似乎有帮助吗?我想要一些可绘制的 xml 代码示例

【问题讨论】:

    标签: android android-layout android-imageview android-canvas


    【解决方案1】:

    您可以在 XML 中创建:

    • 矩形
    • 椭圆形
    • 戒指
    • 渐变
    • 等等

    this 这样的图像很难或不可能在 XML 中创建,尝试使用矢量 (.svg) 文件

    Convert .PNG to .SVG

    附:你可以像这样创建图像:

    <?xml version="1.0" encoding="utf-8"?>
    <selector
      xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape>
                <solid android:color="#EC6118"/>
                <corners android:bottomRightRadius="7dp"
                     android:bottomLeftRadius="0.1dip"
                     android:topLeftRadius="7dip"
                     android:topRightRadius="0.1dp"/>
            </shape>
        </item>
    </selector>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-28
    • 1970-01-01
    • 2014-12-06
    • 1970-01-01
    相关资源
    最近更新 更多