0

enter image description here

I want to create a layout like this and handle click event based on irregular sahpes. but I don't know how to do this any help would be appreciated.

Muhammad Zeshan
  • 104
  • 3
  • 13

1 Answers1

1

Using a RelativeLayout. Make sure the circle comes after the squares in the xml, so it'll be in front of them.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_purple" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/centerLine"
    android:orientation="horizontal" >

    <ImageView
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_marginRight="2dp"
        android:layout_weight="1"
        android:src="@android:color/holo_orange_dark" />

    <ImageView
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_marginLeft="2dp"
        android:layout_weight="1"
        android:src="@android:color/holo_green_dark" />
</LinearLayout>

<View
    android:id="@+id/centerLine"
    android:layout_width="match_parent"
    android:layout_height="4dp"
    android:layout_centerVertical="true"
    android:background="@android:color/holo_purple" />

<LinearLayout
    android:id="@+id/bottomSquares"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/centerLine"
    android:layout_centerVertical="true"
    android:orientation="horizontal" >

    <ImageView
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_marginRight="2dp"
        android:layout_weight="1"
        android:src="@android:color/holo_red_light" />

    <ImageView
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_marginLeft="2dp"
        android:layout_weight="1"
        android:src="@android:color/holo_blue_light" />
</LinearLayout>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:background="@drawable/circle" />

</RelativeLayout>

Aviv Ben Shabat
  • 1,013
  • 2
  • 13
  • 32