-1

What should the code be if I want the kind of interface that is shown in the photo? When I touch the image in the ListView,it should expand (enter image description here) and when I touch anywhere around the image, it should disappear (enter image description here).

Nikhil PV
  • 1,014
  • 2
  • 16
  • 29
Akshit Bhalla
  • 11
  • 1
  • 8

1 Answers1

1

try this using custom dialog you can achieve this

enter image description here

create a custom_layout file like this

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

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#5a000000"
    android:padding="5dp"
    android:text="Title"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />

<ImageView
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:src="@drawable/disha2" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/ic_favorite_fill" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/ic_favorite_fill" />


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/ic_favorite_fill" />


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/ic_favorite_fill" />

</LinearLayout>

</LinearLayout>

now in activity file add this code for custom dialog

final Dialog filterDialog = new Dialog(this);
filterDialog.setContentView(R.layout.custom_layout);
Window window = filterDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,   WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);
filterDialog.show();

ask me in case of any query

AskNilesh
  • 67,701
  • 16
  • 123
  • 163