Android нарисованная пользовательская форма обводит несколько элементов - PullRequest
0 голосов
/ 11 мая 2018

У меня есть пользовательская фигура, которую я пытаюсь создать как фон для вкладки.

Это желаемый результат:

end result

Я пытаюсь с помощью этого шага создать фон активной вкладки.

У меня фон другого цвета, поэтому я могу видеть, что сейчас делает.

Это то, что я имею до сих пор: This is what I have so far

Но при попытке добавить штрих к фигуре это происходит: Trying to add the stroke

Кто-нибудь имеет представление о том, как я могу получить результат, который я изложил выше (с радиусом угла 'и ходом)?

Вот код для рисования (drawable/tab_active.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="100dp"
                android:height="40dp" />
            <solid android:color="#13a89e" />
            <stroke
                android:width="2dp"
                android:color="@color/warmGray" />
            <corners
                android:topRightRadius="0dp"
                android:topLeftRadius="32dp"
                android:bottomLeftRadius="0dp"
                android:bottomRightRadius="32dp" />
        </shape>
    </item>

    <!-- This rectangle for the left side -->
    <item
        android:right="100dp"
        android:left="-100dp"
        android:top="-100dp"
        android:bottom="-100dp">
        <rotate
            android:fromDegrees="45">
            <shape android:shape="rectangle">
                <solid android:color="#13a89e" />
                <stroke
                    android:width="2dp"
                    android:color="@color/warmGray" />
                <padding
                    android:bottom="0dip"
                    android:left="0dip"
                    android:right="0dip"
                    android:top="0dip" />

                <corners
                    android:topRightRadius="0dp"
                    android:topLeftRadius="32dp"
                    android:bottomLeftRadius="0dp"
                    android:bottomRightRadius="32dp" />
            </shape>
        </rotate>
    </item>

    <!-- This rectangle for the right side -->
    <item
        android:right="-100dp"
        android:left="100dp"
        android:top="-100dp"
        android:bottom="-100dp">
        <rotate
            android:fromDegrees="45">
            <shape android:shape="rectangle">
                <solid android:color="#ffffff" />
                <stroke
                    android:width="2dp"
                    android:color="@color/warmGray" />

                <corners
                    android:topRightRadius="32dp"
                    android:topLeftRadius="32dp"
                    android:bottomLeftRadius="32dp"
                    android:bottomRightRadius="32dp" />
            </shape>
        </rotate>
    </item>
</layer-list>

А потом я вызываю это с помощью:

<View
    android:layout_centerInParent="true"
    android:layout_width="100dp"
    android:layout_height="40dp"
    android:background="@drawable/tab_active"
    android:scaleY="-1" />
...