android - android中的滑动抽屉布局问题

标签 android layout slidingdrawer

嗨,我已将滑动抽屉放入我的应用程序中

但是如果抽屉打开,则需要如下图所示的空间

enter image description here

如果它很接近,那么它看起来像

enter image description here

enter image description here

我的布局如下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:gravity="bottom" android:background="@drawable/androidpeople">
    <LinearLayout
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:orientation="vertical">
    <Button android:id="@+id/Button01" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Content">
        </Button>
        <Button android:id="@+id/Button02"
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Content">
         </Button>
        <Button android:id="@+id/Button03" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Content">
        </Button>
        <Button android:id="@+id/Button01" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Content">
        </Button>
        <Button android:id="@+id/Button02"
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Content">
         </Button>
        <Button android:id="@+id/Button03" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Content">
        </Button>

    </LinearLayout>
    <SlidingDrawer 
        android:layout_width="wrap_content" 
        android:id="@+id/SlidingDrawer" 
        android:handle="@+id/slideHandleButton" 
        android:content="@+id/contentLayout" 
        android:padding="10dip" 
        android:layout_height="250dip">
        <Button android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/slideHandleButton" 
            android:background="@drawable/closearrow">
        </Button>
        <LinearLayout android:layout_width="wrap_content" 
            android:id="@+id/contentLayout" 
            android:orientation="vertical" 
            android:gravity="center|top" 
            android:padding="10dip" 
            android:background="#C0C0C0" 
            android:layout_height="wrap_content">


        <Button android:id="@+id/Button01" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Content">
        </Button>
        <Button android:id="@+id/Button02"
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:text="Content">
         </Button>
        <Button android:id="@+id/Button03" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Content">
        </Button>
</LinearLayout>
    </SlidingDrawer>
</LinearLayout>

我的问题是,即使抽屉关闭,它也会占用空间,我想将其删除,以便屏幕顶部的第一个按钮可以放下

最佳答案

尝试将最外层布局更改为relativelayout。这应该允许滑动布局在展开时与其上方的线性布局重叠。

关于android - android中的滑动抽屉布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6044094/

相关文章:

java - 堆栈溢出错误 : LinkedList & ArrayList deserialization

android - 重新使用具有主题相关颜色的渐变可绘制对象

layout - SWT更新/重绘/布局问题

android - DrawerLayout.openDrawer 有时不工作

android - 禁用 NavigationDrawer 图标的幻灯片动画

java - Android 中的 fragment 不必要地重复多次

java - 如何构建简单的 Android 应用程序

java - 为什么我的 JLabels 和 JTextFields 没有出现在 JPanel 中?

java - 使用嵌套面板

android - 在 Android 中禁用 SlidingDrawer 下的图层