android - 设置 slider 抽屉高度

标签 android

我的应用程序中有一个 slider 抽屉。如果我将 wrap_content 设置为 layout_height 字段的值, slider 抽屉将在整个屏幕上拉伸(stretch)。使用常量作为高度也不是一个好的选择。 是否可以有一个 slider 抽屉及其内容的高度?

  <LinearLayout 
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" 
  android:id="@+id/frameLayout" 
  android:layout_gravity="bottom"
  android:orientation="vertical">
    <View
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1" 
      android:background="@color/blue"/>
    <SlidingDrawer 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" 
        android:handle="@+id/handle" 
        android:content="@+id/content"
        android:id="@+id/slide" 
        android:orientation="vertical">
    <RelativeLayout android:id="@+id/handle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/list_header"> 
         <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="@dimen/padding"
            android:textColor="@color/black"
            android:textStyle="bold"
            android:text="@string/ingredients_list_title"/>
         <ImageView
            android:id="@+id/handle_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="@dimen/padding"
            android:src="@drawable/arrow_up"
         />
    </RelativeLayout>
    <RelativeLayout android:id="@+id/content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/list_row_background">
        <LinearLayout android:id="@+id/list_ant_title"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_above="@+id/gallery"
             android:orientation="vertical">
              <ListView 
                android:id="@+id/listview"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:divider="@drawable/divider"
                android:cacheColorHint="@color/transparent"
                android:fadingEdge="none"/>
        </LinearLayout>
        <Gallery 
            android:id="@+id/gallery"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:layout_alignParentBottom="true"
            android:background="@drawable/list_row_background"/>
    </RelativeLayout>
</SlidingDrawer>

最佳答案

容器是什么?线性布局?添加另一个空元素,并将它们的权重都设置为 1。

关于android - 设置 slider 抽屉高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4088863/

相关文章:

java - 使用 AppCompat 在 Android 中为按钮着色

android - SQLite 查询 : between

android - android中的SharedPreference问题

android - 与 VirtualBox 机器一起运行 Android 模拟器

Android 在通话期间播放音频文件

android - 键错误的 fragment 不再存在

java - 当应用程序在后台时停止服务

android - 无法获取提供程序 android.arch.lifecycle.LifecycleRuntimeTrojanProvider : java. lang.ClassNotFoundException

android - 使用 PJSIP 编译 Openh264

android - 在 ViewPager 中按需加载内容