-1

How can I achieve following kind of functionality. I want to click on a list item and show a list of items that appears from bottom till middle of screen. Further, once user selects this item then this panel closes itself. Following is a snapshot of android dialler, which appears from bottom on clicking the dialler icon and slides back to bottom once back button is pressed.

How to make a dialog slide from bottom to middle of screen in android

I found above mentioned thread, but I was not able to achieve it the way it happens for following dialler. The solution in above thread allows dialog to slide up from bottom till middle of screen but its width does not takes the entire screen size.

It will be nice if someone can guide me to the right direction.

Dialler

Community
  • 1
  • 1
kuldeep
  • 817
  • 10
  • 27

2 Answers2

0

Use this animation while showing your UI

<?xml version="1.0" encoding="utf-8"?>
 <set xmlns:android="http://schemas.android.com/apk/res/android">
   <translate android:fromYDelta="75%p" android:toYDelta="0%p" 
    android:fillAfter="true"
 android:duration="500"/>
</set>

this will slide from bottom to up.

Vishwajit Palankar
  • 3,033
  • 3
  • 28
  • 48
0

add the code below when dialog is created

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog);
    WindowManager.LayoutParams lp = this.getWindow().getAttributes();
    lp.width = UIUtil.getScreenWidth(getContext());
    lp.gravity = Gravity.BOTTOM;
    this.getWindow().setAttributes(lp);
}


 <style name="dialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

you should also set a theme for the dialog, call super(context, R.style.dialogTheme) in its constructor

rainash
  • 864
  • 6
  • 15
  • @k2ibegin I use UIUtil to get the screen witdth you use context.getResources().getDisplayMetrics().widthPixels to achieve it – rainash Jul 06 '15 at 14:32
  • I tried but still the same result ! the dialog is coming up but same at the center of the screen and does not takes whole screen width ! – kuldeep Jul 06 '15 at 15:16