我正在创建一个应用程序,它包含一个标题,右侧有一个按钮,当我点击它时应该向左滑动 ListView (类似于 Facebook 中的聊天列表)
-->
当我在没有将 ListView 放入其中的情况下包含此 header 时,它工作正常。但是现在我将这个 ListView 插入到 header 的 .xml
文件中(因为 header 始终显示给用户,他可以在为他显示的任何布局中单击此 ListView 按钮).
问题是我想将此 header 包含到所有其他布局中,而不改变它们的外观,并在他每次单击按钮时显示此列表。
我搜索并找到了很多答案,但每个解决方案都与我在每个页面中之前的屏幕截图中所做的相同,这对于多个页面来说不是一个乐观的解决方案。
*我正在使用 API 级别 10,想在不使用 Actionbar
的情况下找到解决方案。
如果更多信息有帮助,请告诉我,我们将不胜感激。 提前致谢。
更新我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/GeneralRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:id="@+id/rel_layout"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:background="@android:color/white" android:layout_alignParentRight="true">
<LinearLayout android:id="@+id/fake_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"></LinearLayout>
<ListView android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@android:color/background_dark"
></ListView>
</RelativeLayout>
<RelativeLayout android:id="@+id/rel_layout_second"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<LinearLayout android:id="@+id/lin_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/background_light"
android:orientation="vertical"
android:layout_centerHorizontal="true" android:layout_alignParentTop="true">
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="slide"
android:layout_gravity="right|center"></Button>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
最佳答案
尝试为具有 android:visibility="gone"
的 ListView
和同一用户中的所有其他组件创建一个 RelativeLayout
另一个 RelativeLayout
中的接口(interface)。
然后根据菜单的打开或关闭状态更改其可见性。
关于android - Android 滑动 ListView 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14684094/