Search code examples
androidtranslationviewgroup

trying to display a different menu


I'm trying to make my menu appear from the right of the screen like in the facebook app, I had tried to build a custom view group to do so but I have trouble with it when refreshing the content that I explained several times in that forum and I haven't find help yet, so i'm trying differently.

My new idea is to have a horizontal linear layout witch contains two ones in "fill_parent" :

<?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="horizontal" >

    <LinearLayout
        android:id="@+id/around_selection_content_linear_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/yellow"
        android:orientation="vertical" >
    </LinearLayout>

    <LinearLayout
        android:id="@+id/around_selection_menu_linear_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray"
        android:orientation="vertical" >
    </LinearLayout>

</LinearLayout>

and then I override my menu button, to do what I want, I tried to use

myLinearLayout.scrollTo(200,0);

but it does nothing ( could you explain me why ?)

and then I tried animation

TranslateAnimation translateAnimation = new TranslateAnimation(0, 200, 0, 0);
            translateAnimation.setDuration(10000);
myLinearLayout.startAnimation(translateAnimation);

but it does nothing, and if I remembre well, the button on my menu will never be clickable this way, because clicking at this place would in fact clicking on the first layout.


Solution

  • This has been answered in a similar question, This answer SlidingFacebookMenu has a really good example and some source code you can use. Hope that helps.