Android xml中的三角形设计

标签 android xml drawable xml-drawable

是否可以使用形状通过 xml 进行此类设计,如果可以,我该怎么做 对于加载和内存图像为 png 或具有大量形状的可绘制图像,哪种方法更有效? enter image description here

最佳答案

您可以使用 XML triangle.xml 绘制三角形

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <rotate
            android:fromDegrees="-45"
            android:pivotX="270%"
            android:pivotY="70%"
            android:toDegrees="45">
            <shape android:shape="rectangle">
                <stroke
                    android:width="1dp"
                    android:color="@android:color/transparent" />
                <solid android:color="#ffffff" />
            </shape>
        </rotate>
    </item>
</layer-list>

编辑:旋转形状

enter image description here

关于Android xml中的三角形设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45028156/

相关文章:

android - 自定义对话框或对话框主题 Activity

Android - 包括 GitHub 库 ActionBar PullToRefresh

android - 如何使微调对话框显示当前选定的项目?

java - OnKeyListener() 没有执行

PHP XML 错误 - 文档末尾有多余内容

android - 关于android Drawable getBounds return Rect(0, 0 - 0, 0)

xml - 为什么我的 XSLT 样式突然停止解析产品广告 API XML 响应?

python - 使用 Python,当同级元素的标签是我要查找的字符串时,如何获取 XML 元素的文本?

Android可绘制资源: Dynamically change an icon color/"background"?

android - 如果无法加载 url,如何加载占位符?