[英]How to draw a triangle shape attached to a Rectangle?
I am newbie in designing vector drawables in android. 我是设计Android中矢量可绘制对象的新手。
I would like to design like following but not sure how to accomplish this 我想设计如下,但不确定如何完成此操作
I have tried the following code snippet 我已经尝试了以下代码片段
<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>
But I got only the following result 但是我只有以下结果
Please help me get the solution 请帮我解决
I have made some 9-patch images matching your need. 我已经制作了一些符合您需求的9补丁图像。 Using this drawable you can place each one as you wish on the screen according to your case: 使用此可绘制对象,您可以根据情况在屏幕上随意放置每个对象:
triangle_bg.xml 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>
You can download drawables here . 您可以在此处下载绘图。 The original PSD file used to build 9-patches is also available here . 这里也提供了用于构建9个补丁的原始PSD文件。
The final output would look like this: 最终输出如下所示:
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.