Issue
I have a layer-list, with a oval at the start, a line in the middle and a rectangle at the end; booth oval and rectangle have 8dpx8dp and the line I've been trying using no height or 32dp of height x 8dp width
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:gravity="top"
android:bottom="40dp"
android:top="0dp">
<shape android:shape="oval">
<solid android:color="@color/colorAccent" />
<size android:width="8dp" android:height="8dp"
/>
</shape>
</item>
<item
android:top="0dp"
android:bottom="0dp"
>
<rotate
android:fromDegrees="90"
android:toDegrees="90">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
android:dashWidth="1dp"
android:dashGap="2dp"
/>
<size android:width="8dp"
/>
</shape>
</rotate>
</item>
<item
android:gravity="bottom"
android:top="40dp"
android:bottom="0dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorAccent" />
<size android:width="8dp" android:height="8dp"
/>
</shape>
</item>
</layer-list>
This is the ImageView where i'm displaying it.
<ImageView
android:layout_width="8dp"
android:layout_height="@dimen/image_large"
android:src="@drawable/place_selector_left_image"
android:layout_gravity="center_vertical"
/>
but It don't work as expected the line don't take the full height I assigned to it.
Solution
It seems that when I created the line is horizontal so it can only take the width of the container, and when I rotated it it wasnt' the height I wanted, I added left and right offset to the item. This is my final code.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="40dp"
android:top="0dp">
<shape android:shape="oval">
<solid android:color="@color/colorAccent" />
<size
android:width="8dp"
android:height="8dp" />
</shape>
</item>
<item
android:bottom="8dp"
android:top="8dp"
android:right="-32dp"
android:left="-32dp">
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
android:dashWidth="1dp"
android:dashGap="2dp" />
<size android:width="8dp"
android:height="32dp"
/>
</shape>
</rotate>
</item>
<item
android:bottom="0dp"
android:top="40dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorAccent" />
<size
android:width="8dp"
android:height="8dp" />
</shape>
</item>
</layer-list>
Answered By - Chris Gomez
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.