Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to design like layout in android

I want to design like layout. for example: when user touch like button then show a layout above it to show stickers.

please see this picture too understand my mean:

enter image description here

Can you guide me?

like image 236
ydstsh Avatar asked Mar 14 '23 12:03

ydstsh


2 Answers

you have to keep a hidden linear layout above your layout for like button, and make it visible when like is clicked.

this hidden layout will contain your stickers:

example :

layout will look something like this:

<LinearLayout
    android:id="@+id/buttonContainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:visibility="gone"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/option1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:scaleType="fitCenter"
        android:src="@drawable/image1" />

    <ImageView
        android:id="@+id/option2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:scaleType="fitCenter"
        android:src="@drawable/image2" />

    <ImageView
        android:id="@+id/option3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:scaleType="fitCenter"
        android:src="@drawable/image3" />
</LinearLayout>

place it on top of layout for like button, customize it as per your need

and on click of your like button you have to make it visible like this;

findViewById(R.id.buttonContainer).setVisibility(View.VISIBLE);

and once an image is selected hide the view again like this:

 findViewById(R.id.buttonContainer).setVisibility(View.GONE);

hope this will help.

like image 194
Rahul Tiwari Avatar answered Mar 28 '23 21:03

Rahul Tiwari


Rahul Tiwari has Nice Solution, Also you can have Relative Layout

inside Relative Layout You have Horizontal Linear Layout

And Finally set animation to Hide And Show Horizontal Linear Layout

Horizontal Linear Layout should be Forground of view

read it to learn basic of animation

like image 24
Hossein Kurd Avatar answered Mar 28 '23 22:03

Hossein Kurd