简体   繁体   English

自定义ImageView形状在xml中可绘制,就像在Android中这样

[英]Custom ImageView shape drawable in xml like this one in android

I want to create an ImageView like this one. 我想创建一个像这样的ImageView。 I know it's a combination of a rectangle and a triangle shape, 我知道这是矩形和三角形的结合,

but I really don't know how to implement it. 但我真的不知道如何实现。

Is it possible in XML?. 是否可以使用XML? Does layer-list seem to help in this case?. 在这种情况下,层列表似乎有帮助吗? I would like to have some example drawable xml codes 我想要一些可绘制的xml代码示例

In XML you can create: 在XML中,您可以创建:

  • rectangle 长方形
  • oval 椭圆
  • ring
  • line 线
  • gradient 梯度
  • and more 和更多

Image like this difficult or impossible create in XML, try use vector (.svg) files 难以或无法在XML中创建此类图像,请尝试使用矢量(.svg)文件

Convert .PNG to .SVG 将.PNG转换为.SVG

PS you can create image like this: PS您可以创建这样的图像:

长方形

<?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM