Sony
Sony

Reputation: 7196

Xml drawable not showing correctly in app

I created an XML drawable like this a part from the image

and the xml is

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:top="5dp">
        <shape
            android:dither="true"
            android:shape="rectangle">
            <solid android:color="@color/cardview_light_background" />
        </shape>
    </item>

    <item
        android:gravity="top"
        android:top="2dp">
        <shape android:shape="line">
            <size android:height="2dp" />
            <stroke
                android:width="1dp"
                android:color="@color/colorAccent"
                android:dashGap="48dp"
                android:dashWidth="@dimen/activity_default_margin" />
        </shape>
    </item>

    <item
        android:gravity="top"
        android:left="32dp"
        android:top="2dp">
        <shape android:shape="line">
            <size android:height="2dp" />
            <stroke
                android:width="1dp"
                android:color="#f9607d"
                android:dashGap="48dp"
                android:dashWidth="@dimen/activity_default_margin" />
        </shape>
    </item>

</layer-list>

The image above is from the preview in the android studio. When the image is displayed in the emulator it shows a single line instead of the dashed lines. How can I fix the issue?

Upvotes: 1

Views: 154

Answers (1)

phatnhse
phatnhse

Reputation: 3920

Add this line to your ImageView in your xml layout

android:layerType="software"

Upvotes: 1

Related Questions