1

我试图让我的菜单像在 facebook 应用程序中一样从屏幕右侧显示,我曾尝试构建一个自定义视图组来这样做,但是在刷新我多次解释的内容时我遇到了麻烦论坛,我还没有找到帮助,所以我尝试不同。

我的新想法是在 "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>

然后我覆盖我的菜单按钮,做我想做的事,我尝试使用

myLinearLayout.scrollTo(200,0);

但它什么也没做(你能解释一下为什么吗?)

然后我尝试了动画

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

但它什么也没做,如果我没记错的话,我的菜单上的按钮永远不会以这种方式点击,因为点击这个地方实际上会点击第一个布局。

4

1 回答 1

1

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.

于 2012-03-14T09:28:04.383 回答