I need triangle shape at top right corner with image inside. Triangle shape should be dynamic depend on parent layout.
This is currently looks.
I have looked into may post and created upto above image.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/triangle_shape"
android:gravity="right"
android:layout_gravity="right"
android:layout_alignParentRight="true"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/more_hdpi"
android:layout_centerVertical="true"
android:layout_centerHorizontal="false"
/>
</RelativeLayout>
</RelativeLayout>
triangle_shape.xml
<?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="0%"
android:pivotY="-45%" >
<shape
android:shape="rectangle" >
<stroke android:color="@color/yellow" android:width="10dp"/>
<solid
android:color="@color/yellow" />
</shape>
</rotate>
</item>
</layer-list>
But, as you see i have fix width and image look at bottom of the shape i need it in center of the shape like:
This is what i want.
when i look in android studio deign view it loos like height and width is double of the shape. That is because shape is actually rectangle and it is rotated.
Currently looks in android studio preview.
I look in many post like this but didn't get solution in any. Any help would be greatly appreciated.