如何绘制附加到矩形的三角形?
How to draw a triangle shape attached to a Rectangle?
我是 android 中设计矢量绘图的新手。
我想设计如下,但不知道如何实现
我试过下面的代码片段
<item>
<rotate
android:fromDegrees="-45"
android:pivotX="0%"
android:pivotY="0%"
android:toDegrees="-45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
<stroke
android:width="1dp"
android:color="#fffff" />
<corners
android:bottomRightRadius="@dimen/dim_200dp"
android:bottomLeftRadius="@dimen/dim_50dp"
android:topRightRadius="@dimen/dim_50dp"
android:topLeftRadius="@dimen/dim_50dp"></corners>
</shape>
</rotate>
</item>
但是我得到的只有下面的结果
请帮我解决问题
我制作了一些符合您需要的 9 补丁图像。使用此可绘制对象,您可以根据自己的情况将每一个都放置在屏幕上:
triangle_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="90dp"
android:height="160dp"
android:bottom="137dp">
<nine-patch android:src="@drawable/top_bg"/>
</item>
<item
android:width="90dp"
android:height="60dp"
android:top="137dp">
<nine-patch android:src="@drawable/bottom_bg"/>
</item>
</layer-list>
您可以下载绘图 here. The original PSD file used to build 9-patches is also available here。
最终输出如下所示:
希望对您有所帮助。
我是 android 中设计矢量绘图的新手。
我想设计如下,但不知道如何实现
我试过下面的代码片段
<item>
<rotate
android:fromDegrees="-45"
android:pivotX="0%"
android:pivotY="0%"
android:toDegrees="-45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
<stroke
android:width="1dp"
android:color="#fffff" />
<corners
android:bottomRightRadius="@dimen/dim_200dp"
android:bottomLeftRadius="@dimen/dim_50dp"
android:topRightRadius="@dimen/dim_50dp"
android:topLeftRadius="@dimen/dim_50dp"></corners>
</shape>
</rotate>
</item>
但是我得到的只有下面的结果
请帮我解决问题
我制作了一些符合您需要的 9 补丁图像。使用此可绘制对象,您可以根据自己的情况将每一个都放置在屏幕上:
triangle_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="90dp"
android:height="160dp"
android:bottom="137dp">
<nine-patch android:src="@drawable/top_bg"/>
</item>
<item
android:width="90dp"
android:height="60dp"
android:top="137dp">
<nine-patch android:src="@drawable/bottom_bg"/>
</item>
</layer-list>
您可以下载绘图 here. The original PSD file used to build 9-patches is also available here。
最终输出如下所示:
希望对您有所帮助。