1

In my app there is the view says googleBtn. If i press on it then the Animation occurs and the Menu view goes to upar side. and if i press that button again then the menu will open. See the Below images.

While menu is open:

enter image description here

After menu is closed:

enter image description here

Now the problem is animation occurs right to hide the Menu. But after finishing the animation i want to fix the menu layout to that position (As like second image) but it not happend like that.

Right now if the menu is open and i press google button then the menu getting closed. but after finishing the animation it comes to normal position.

I have try with to fix the scroll y position of the Layout but still not get success.

The code for the Button click is below:

case R.id.googleBtn:
        if(menu){   
            menuLayout.startAnimation(hideMenu);
            menu = false;
        }
        else{
            menuLayout.startAnimation(showMenu);
            menu = true;
        }
        break;

and the layout of the Menu is like below:

  <LinearLayout android:id="@+id/menuLayout" 
    android:layout_height="wrap_content" android:layout_width="fill_parent"
    android:gravity="center_horizontal" 
    android:background="@drawable/slide">
    <View android:layout_height="80dp" android:layout_width="80dp"
        android:layout_marginBottom="25dp" android:id="@+id/googleBtn"
        android:background="#00000000" android:layout_gravity="bottom"/>    

</LinearLayout>

So why i am not able to fix the scroll value? ?

Need help regarding this.

Update

This are my code for the Animation:

For Menuhide:

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

<translate 
    android:fromYDelta="0" 
    android:toYDelta="-70%" 
    android:duration="1000"
    android:fillEnabled="true"
    android:fillAfter="true"
    />

And for MenuShow:

    <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate 
        android:fromYDelta="-70%" 
        android:toYDelta="0" 
        android:duration="1000"/>
</set>
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188

2 Answers2

1

i think you are searching for this Android: Sliding Drawer

here a Panel is a container which contain your view and its also support animation, fling etc.

Misc widget source you can find here http://code.google.com/p/android-misc-widgets/source/browse/#svn%2Ftrunk%2Fandroid-misc-widgets%2Fsrc%2Forg%2Fmiscwidgets%2Fwidget

Community
  • 1
  • 1
Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
1

You probably need to set android:fillEnabled="true" and/or android:fillAfter="true".

If that does not work you can apply the change to the layout in AnimationListener#onAnimationEnd.

Rich Schuler
  • 41,814
  • 6
  • 72
  • 59
  • thanks for the answer. But where should i have to set it? i mean in the Animation or in the Layout xml ? – Shreyash Mahajan Apr 11 '12 at 05:30
  • its not working. I have updated the code with the animation file. Please check it and give me solution. – Shreyash Mahajan Apr 11 '12 at 05:46
  • please i need help. Just tell me why i am not able to set the scrollY to the LinearLayout ? As i want to set it when ever the hide animation finish. So it fix the Menu as like my second image in question. – Shreyash Mahajan Apr 11 '12 at 06:15