背景中的可绘制XML箭头不起作用

时间:2018-08-30 05:58:27

标签: android xml-drawable

我在drawable xml中做了一个箭头,我想将其用作textview的背景。但是输出不像我期望的那样。我想在给定的图片中显示第一个箭头。怎么做?是否可以使用drawable xml

输出: enter image description here

预期: enter image description here

我的可绘制xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- Colored rectangle-->
    <item>
        <shape android:shape="rectangle">
            <size
                android:width="@android:dimen/thumbnail_height"
                android:height="40dp" />
            <solid android:color="#5EB888" />
            <corners android:radius="0dp"/>
        </shape>
    </item>

    <!-- This rectangle for the top arrow edge -->
    <!-- Its color should be the same as the layout's background -->
    <item
        android:top="-50dp"
        android:bottom="65dp"
        android:right="-30dp">
        <rotate
            android:fromDegrees="45">
            <shape android:shape="rectangle">
                <solid android:color="#ffffff" />
            </shape>
        </rotate>
    </item>

    <!-- This rectangle for the lower arrow edge -->
    <!-- Its color should be the same as the layout's background -->
    <item
        android:top="65dp"
        android:bottom="-50dp"
        android:right="-30dp">
        <rotate
            android:fromDegrees="-45">
            <shape android:shape="rectangle">
                <solid android:color="#ffffff" />
            </shape>
        </rotate>
    </item>
</layer-list>

适配器布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center"
    android:layout_marginLeft="10dp"
    android:background="#123"
    android:layout_marginBottom="5dp"
    >

    <TextView
        android:id="@+id/wifiNameShowTvId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:padding="10dp"
        android:textSize="20sp"
        android:background="@drawable/custom_shape_ssid"
        android:textColor="#f9f9f9"
        android:text="dkjfsjkfhskjdfhksjdfh "

        />

</LinearLayout>

。,。,。,。,。,。,。,。,。,。,。,。,。,。,。,。,。,。

1 个答案:

答案 0 :(得分:0)

尝试

if (condition1 != condition2)

并将其放在您的布局背景上

'!'

输出

enter image description here