简体   繁体   English

如何绘制附加到矩形的三角形?

[英]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.

相关问题 如何在android中绘制复杂的形状,包含三角形,矩形和笔划 - How to draw complicated shape in android, with contain of triangle, rectangle and stroke 如何在xml drawable android中绘制矩形内部内部末端三角形形状? - How to draw a rectangle inner inside end triangle shape in xml drawable android? Android如何以编程方式创建三角形和矩形形状? - Android how to create triangle and rectangle shape programmatically? 如何在列表视图中绘制圆角矩形形状的项目 - How to draw rounded rectangle shape items in a listview Android如何以编程方式绘制圆角矩形形状 - Android how to draw Rounded Rectangle shape programmatically 如何绘制三角形形状并将其添加到相对或线性布局android - How to draw triangle shape and add it into relative or linear layout android 如何在 VideoView 周围绘制带有边框阴影形状的矩形? - How can I draw rectangle with a border shadow shape around VideoView? 如何绘制具有可变笔触宽度的Android Shape Rectangle - How to draw a Android Shape Rectangle with variable stroke width 如何在android中绘制一侧交叉的矩形形状 - how to draw the shape of rectangle whose one side is crossed in android 在Android中使用XML形状设置绘制矩形 - Draw rectangle with XML shape settings in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM