Reputation: 69
I'm trying to draw in Android XML the form in the image. But so far none of my attempts are successful. How can I do it?
Thanks in Advance
Upvotes: 0
Views: 319
Reputation: 1079
If you use a RelativeLayout you can do a black rectangle and then put a white triangle image over the top. I don't see how you would get a Triangle without the image.
OK, I must have been a little brain dead yesterday. Here is a better solution.
The layout:
<RelativeLayout android:layout_width="300dp"
android:layout_height="100dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:background="@android:color/black">
<View android:layout_width="100dp"
android:layout_alignParentRight="true"
android:layout_height="match_parent"
android:background="@drawable/background_triangle_right"/>
</RelativeLayout>
The Drawable that makes the triangle:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="87%"
android:pivotY="140%">
<shape
android:shape="rectangle">
<stroke android:color="@android:color/white" android:width="10dp"/>
<solid
android:color="@android:color/white"/>
</shape>
</rotate>
</item>
</layer-list>
Upvotes: 1