在图像上方的android中绘制功能区

时间:2019-03-20 02:00:43

标签: java android drawable

我有一个ImageView,背景为图片。我想在图像上方绘制一条丝带来描述它。我尝试了以下代码,但三角形为黑色。因此它不能应用于带有背景图像的视图。

<item>
    <shape android:shape="rectangle">
        <size
                android:width="100dp"
                android:height="40dp"/>
        <solid android:color="@android:color/holo_orange_dark"/>
        <corners android:radius="6dp"/>
    </shape>
</item>


<item
        android:top="-26dp"
        android:bottom="31dp"
        android:left="-90dp"
        android:right="75dp">
    <rotate
            android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/black"/>
        </shape>
    </rotate>
</item>

将三角形颜色设置为透明也不起作用。我想将矩形遮盖住矩形,如下所示:

Banner sample

1 个答案:

答案 0 :(得分:0)

根据我的建议,您可以将vector用于功能区并检查此link for imageview on imageview

  <?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
    android:fillColor="#76c304"
    android:strokeWidth="1"
    android:pathData="M9.85 12L3.3 18.55L24 18.55L24 6.63L3.3 6.63L9.85 12Z" /></vector>

 <?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
    android:fillColor="#7c2a58"
    android:strokeWidth="1"
    android:pathData="M6.75 5.56L3.98 8.33L23.76 8.33L23.76 2.67L3.98 2.67L6.75 5.56Z" />
<path
    android:fillColor="#7c2a58"
    android:strokeWidth="1"
    android:pathData="M6.75 12.24L3.98 15.01L23.76 15.01L23.76 9.35L3.98 9.35L6.75 12.24Z" />
<path
    android:fillColor="#7c2a58"
    android:strokeWidth="1"
    android:pathData="M6.75 18.56L3.98 21.33L23.76 21.33L23.76 15.67L3.98 15.67L6.75 18.56Z" /></vector>
相关问题