I'm trying to add a hexagonal custom frame to an ImageView
.
Approach I tried :
Created a hexagon shape in drawable
folder.
drawable/ic_hexagon.xml
file
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:thicknessRatio="1.9"
android:useLevel="false">
<solid android:color="@android:color/transparent"/>
<path android:fillColor="#00ffffff"
android:pathData="m723,314c-60,103.9 -120,207.8 -180,311.8 -120,0 -240,0 -360,0C123,521.8 63,417.9 3,314 63,210.1 123,106.2 183,2.2c120,0 240,0 360,0C603,106.2 663,210.1 723,314Z"
android:strokeColor="#000000" android:strokeWidth="10"/>
</shape>
Then created filter.xml
file using layer-list
and added it as the background of the ImageView.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/img"/>
<item android:drawable="@drawable/ic_hexagon"/>
</layer-list>
layout.xml
file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/filter"/>
</LinearLayout>
I followed this answer. But I wasn't able to apply this answer for custom hexagon. This is a sketch of the layout I'm trying to achieve.
PS : I'm trying to use the hexagon as a frame. The hexagon shape is working. But it cannot be used as a frame.
Please help me with this. Thanks.