Jatin
Jatin

Reputation: 1670

Custom Shape Button in Android

How can i make a custom shaped button as i drawn in image in Android?

I want to implement ui like below.enter image description here

Can any one help me ?

Thanks in advance.

Upvotes: 1

Views: 875

Answers (1)

aWang
aWang

Reputation: 78

Here are simple way to implement it just use layout, the works layout is FrameLayout

[Graphical Layout] Graphical Layout

[post.png]

post.png

[add_a_video.png]

enter image description here

[layout.xml]

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageButton
    android:id="@+id/imageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageButton4"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:padding="0dp"
    android:src="@drawable/add_a_photo" />

<ImageButton
    android:id="@+id/imageButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/imageButton1"
    android:padding="0dp"
    android:src="@drawable/facebook" />

<ImageButton
    android:id="@+id/imageButton3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/imageButton2"
    android:padding="0dp"
    android:src="@drawable/facebook" />

<ImageButton
    android:id="@+id/imageButton4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageButton2"
    android:layout_below="@+id/imageButton2"
    android:padding="0dp"
    android:src="@drawable/facebook" />

<ImageButton
    android:id="@+id/imageButton5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageButton3"
    android:layout_below="@+id/imageButton3"
    android:padding="0dp"
    android:src="@drawable/facebook" />

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageButton1" >

    <ImageButton
        android:id="@+id/imageButton7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="0dp"
        android:src="@drawable/post" />

    <ImageButton
        android:id="@+id/imageButton6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="0dp"
        android:src="@drawable/add_a_video" />
</FrameLayout>

Upvotes: 1

Related Questions