这是我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
.................................
.................................
<SlidingDrawer
android:layout_width="fill_parent"
android:id="@+id/SlidingDrawer"
android:handle="@+id/slideButton"
android:content="@+id/contentLayout"
android:padding="10dp"
android:layout_height="150dp">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/slideButton"
android:background="@drawable/action_eating">
</Button>
<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/contentLayout"
android:orientation="vertical"
android:gravity="center"
android:padding="10dp"
android:background="#45454F"
android:layout_height="wrap_content">
<Button
android:id="@+id/history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/history"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</ScrollView>
问题是,SlidingDrawer 保留在我的布局底部(这很好),但它仍然在底部太远(我认为它仍然比我的布局低 150dp)。当我单击它时,它会打开但不会在我的布局上滚动,它仍保留在我在布局中显示的所有内容下方。但我需要,当我点击它时,将它滑过我的 View 。当它关闭时,它应该保持在我的布局下方,离我的布局不太远(比如 150dp)。
抱歉我的英语不好。如果您在理解我所说的内容方面有任何问题,请告诉我。谢谢。
最佳答案
将带有内容的LinearLayout
和SlidingDrawer
放入RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
// your content
</LinearLayout>
<SlidingDrawer
android:layout_width="fill_parent"
android:id="@+id/SlidingDrawer"
android:handle="@+id/slideButton"
android:content="@+id/contentLayout"
android:padding="10dp"
android:layout_height="150dp">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/slideButton"
android:background="@drawable/action_eating">
</Button>
<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/contentLayout"
android:orientation="vertical"
android:gravity="center"
android:padding="10dp"
android:background="#45454F"
android:layout_height="wrap_content">
<Button
android:id="@+id/history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/history"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
</ScrollView>
关于android - SlidingDrawer 关闭时显示离底部太远,打开时不与 View 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13991908/