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).
Asked
Active
Viewed 52 times
-1
-
`What should the code be` you should write it on your own. But if you run into some specific problems - then feel free to ask questions, but please be very specific. So what is the specific problem? – Vladyslav Matviienko Jul 14 '17 at 08:38
-
Review this, You may customize as per requirement. https://stackoverflow.com/questions/27954561/show-alertdialog-with-imageview-without-any-padding – Jagdish Bhavsar Jul 14 '17 at 10:02
-
@VladMatvienko I wasn't able to achieve what I have asked in the question. I'm new to all this. I'm just learning. :) – Akshit Bhalla Jul 14 '17 at 11:39
-
@JagdishBhavsar thanks! That was really helpful! :) – Akshit Bhalla Jul 14 '17 at 11:40
1 Answers
1
try this using custom dialog you can achieve this
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