-4

ListViewAndroid

How i can achieve this. What should be used for it, Dialog,Snackbar or popup window with animation. I have to show the list items as in this image.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Umair Iqbal
  • 1,405
  • 2
  • 14
  • 24

2 Answers2

1

you can try this you can use Dialog for that with animation with this code you can create dialog with animation to slide up when dialog show and slide down when dialog dismiss

create Dialog like this

final Dialog customDialog = new Dialog(context, R.style.DialogSlideAnim);
customDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
customDialog.setContentView(R.layout.custom_dialog_filter);
customDialog.setTitle("");
Window window = customDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.BOTTOM);
customDialog.show();

create this theme in style.xml

 <style name="DialogAnimation">
    <item name="android:windowEnterAnimation">@anim/anim_slide_up</item><!--animation file-->
    <item name="android:windowExitAnimation">@anim/anim_slide_down</item><!--animation file-->
    <item name="android:windowFrame">@null</item><!--frame-->
    <item name="android:windowNoTitle">true</item>
</style>

<!-- Animation for dialog box -->
<style name="DialogSlideAnim">
    <item name="colorPrimaryDark">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item> <!--shadow-->
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">true
    </item> <!-- true:  create shadow effect when open dialog -->
    <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>

now create animation file like this anim_slide_up

<?xml version="1.0" encoding="utf-8"?>

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="50%p"
android:toYDelta="0%p" />

now create animation file like this anim_slide_down

<?xml version="1.0" encoding="utf-8"?>

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="50%p"
android:duration="@android:integer/config_longAnimTime"/>

ask me in case of any query

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
1

You can either use Dialog Fragment or Bottom sheet with Recycler view. In what's app I think bottom sheet is used with so many constraints.

So for bottom sheet with Recycler view you can check this or this

And for Dialog Fragment you can check this for how you can display dialog at bottom.

Hope will help you...

Wasim K. Memon
  • 5,979
  • 4
  • 40
  • 55