【问题标题】:Sliding Drawer hides last row of Fragment with GridView滑动抽屉用 GridView 隐藏最后一行 Fragment
【发布时间】:2013-07-06 15:55:44
【问题描述】:

我想在我的 gridview 下方有一个滑动抽屉,这是一个片段。根据屏幕大小,我有两个 xml 版本。较大的屏幕有两个并排的片段,较小的屏幕有一个片段。在碎片下面我需要有抽屉,但它隐藏了我网格的底部元素。一些指示和帮助将非常受欢迎。
这就是我得到的:

我已经尝试了各种变体,这是我目前拥有的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="#ffffff">
    <FrameLayout
            android:id="@+id/fragone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="0dp"
            android:layout_alignParentTop="true"
            android:layout_marginTop="0dp">
    </FrameLayout>
        <SlidingDrawer
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:content="@+id/content"
                android:handle="@+id/handle"
                android:id="@+id/slidingDrawer"
                android:layout_alignParentBottom="true"
                android:layout_marginLeft="0dp"
                android:layout_marginTop="0dp">
            <LinearLayout
                    android:id="@+id/content"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:padding="10dp"
                    android:background="#000000">

                <ListView android:layout_width="fill_parent"
                          android:layout_height="wrap_content"
                          android:id="@+id/lvDrawer"
                          android:divider="@android:color/transparent"
                          android:dividerHeight="10.0sp" />
            </LinearLayout>

            <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/handle"
                    android:src="@drawable/fav_stern" 
                    android:adjustViewBounds="true"/>
        </SlidingDrawer>

</RelativeLayout>

第二个布局应该基本相同,只是在第一个右侧有第二个片段。

【问题讨论】:

  • 小心使用 SliderDrawer,因为它在 API 级别 17 已被弃用。
  • 将您的RelativeLayout 换成LinearLayout 方向为vertical,看看会发生什么
  • @Flynn81 thx,具有完全相同功能的替代方案是什么?@Blundell thx,我曾经尝试过,但它完全隐藏了我的 gridview。另请阅读文档中的某处,您应该使用真实布局
  • 正如 Blundell 提到的,您应该更改为 LinearLayout。但也使用权重!根据所需的滑块大小(权重 = 1),最好将框架布局的权重设置在 5 到 10 之间。
  • @Horschtele 当我这样做时,我会在我的网格视图上得到一个白色的字段,抽屉本身会在其中滑动。

标签: android android-layout android-fragments android-relativelayout slidingdrawer


【解决方案1】:

将片段的底部偏移处理程序的高度。一种方法是使处理程序具有一致的高度并设置底部边距。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-07
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多