Android 如何使SlidingDrawer在显示时推送现有布局?

Android 如何使SlidingDrawer在显示时推送现有布局?,android,Android,主要目的: 我在屏幕上有一个listview显示屏,我想在它的底部有一个滑动抽屉 实际上,我正在通过代码切换SlidingDrawer的“句柄”视图,以显示/隐藏抽屉 我希望通过滑入并“收缩”listview布局来显示我的栏。 当它隐藏以使listview布局返回其原始视图时 现在我有一个固定的listview布局,还有一个透明的占位符供抽屉显示或隐藏 有人能帮我弄清楚这个吗 活动xml: <LinearLayout xmlns:android="http://schemas.androi

主要目的: 我在屏幕上有一个listview显示屏,我想在它的底部有一个滑动抽屉

实际上,我正在通过代码切换SlidingDrawer的“句柄”视图,以显示/隐藏抽屉

我希望通过滑入并“收缩”listview布局来显示我的栏。 当它隐藏以使listview布局返回其原始视图时

现在我有一个固定的listview布局,还有一个透明的占位符供抽屉显示或隐藏

有人能帮我弄清楚这个吗

活动xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Container"
android:id="@+id/layout"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/listview"
        style="@style/Widget.ListView" />
</LinearLayout>

<include
    layout="@layout/delete_bar" />

</LinearLayout>

删除工具栏xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/MarginTopBottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom"
    android:orientation="vertical"
    android:padding="10dp" >

    <my.WrappingSlidingDrawer
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:content="@+id/content"
        android:handle="@+id/handle" >

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <Button
                style="@style/Widget.Button.Wrap"
                android:id="@+id/btn_DeleteBar_delete"
                android:layout_weight="1"
                android:onClick="onClick"
                android:text="@string/w_Delete" />

            <Button
                style="@style/Widget.Button.Wrap"
                android:id="@+id/btn_DeleteBar_cancel"
                android:layout_weight="1"
                android:onClick="onClick"
                android:text="@string/w_Cancel" />
        </LinearLayout>

        <Button
            android:id="@+id/handle"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:visibility="gone" />
    </my.WrappingSlidingDrawer>
</LinearLayout>

我希望这会对你有所帮助

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF4444CC">
<SlidingDrawer android:id="@+id/drawer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:handle="@+id/handle" android:content="@+id/content">

<ImageView android:id="@id/handle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tray_handle_normal"`/>

<Button android:id="@id/content" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="I'm in here!" />

</SlidingDrawer> </FrameLayout>


您可能想查看此答案(可能还有其他答案)。似乎他们也在试图完成类似的事情

使用默认抽屉尝试此操作

actionBarToggle = new ActionBarDrawerToggle(
            this,                  /* host Activity */
            mDrawerLayout,         /* DrawerLayout object */
            R.drawable.ic_drawer,  /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open,  /* "open drawer" description for accessibility */
            R.string.drawer_close  /* "close drawer" description for accessibility */
            ) {public void onDrawerSlide(View drawerView, float slideOffset)
        {
            float moveFactor = (mDrawerList.getWidth() * slideOffset);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) 
            {
                frameLayout.setTranslationX(moveFactor);
            }
            else
            {
                TranslateAnimation anim = new TranslateAnimation(lastTranslate, moveFactor, 0.0f, 0.0f);
                anim.setDuration(0);
                anim.setFillAfter(true);
                frameLayout.startAnimation(anim);

                lastTranslate = moveFactor;
            }
或者使用不同的库来绘制抽屉