Issue
I have a ListView
and its items have an arrow aligned to the end, like this:
The arrow is set in the background, which is a custom drawable:
background_listitem.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@android:color/white" />
</shape>
</item>
<item
android:width="24dp"
android:height="24dp"
android:gravity="right|end|center_vertical"
android:right="@dimen/preferred_margin">
<bitmap android:src="@drawable/ic_chevron_right_black_24dp" />
</item>
</layer-list>
With API > 22 this is working great but 22 and below the background looks like this:
This is how I am setting the background:
listitem_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/listitem_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_listitem"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/preferred_margin">
...
</RelativeLayout>
Is there any way to fix this without adding the arrow as an ImageView
?
Solution
you can change you background_listitem.xml file like this i hope this is help you.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/white"/>
<item>
<bitmap android:src="@drawable/ic_chevron_right_black_24dp"
android:gravity="right|end|center_vertical" />
</item>
</layer-list>
Answered By - Farmer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.