【问题标题】:Android triangle design in xmlxml中的Android三角形设计
【发布时间】:2017-07-11 07:32:56
【问题描述】:

是否可以使用形状使用 xml 进行这样的设计,如果可以,我该怎么做 以及将图像加载和存储为 png 或具有多种形状的可绘制图像更有效?

【问题讨论】:

  • 你可以使用9个补丁图像

标签: android xml drawable xml-drawable


【解决方案1】:

您可以使用 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>

编辑:旋转形状

【讨论】:

    【解决方案2】:

    您可以 tileMode = repeat 和形状使用此可绘制矢量并检查此link

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <rotate
                android:fromDegrees="45"
                android:pivotX="-40%"
                android:pivotY="50%"
                android:toDegrees="90">
                <shape android:shape="rectangle">
                    <stroke
                        android:width="-140dp"
                        android:color="@android:color/transparent" />
                    <solid android:color="@android:color/background_dark" />
                </shape>
            </rotate>
        </item>
    </layer-list>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多