5
我在我的应用程序中有一个滑块抽屉。如果我将wrap_content设置为layout_height字段的值,则滑块抽屉会在整个屏幕上展开。使用常量作为高度也不是一个好的选择。 是否可以有一个滑块抽屉与它的内容的高度?设置滑块抽屉高度
提前致谢!
<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>
这是一个FrameLayout。我已将其更改为LinearLayout并设置权重。但是同样的事情。 – Gratzi 2010-11-04 07:45:29
你可以发布布局吗? – EboMike 2010-11-04 07:46:53
我已将它发布在最初的问题中。我做了一些修复,最后的结论是,如果我为哑视图和抽屉设置权重为1,那么它们的高度都等于屏幕的1/2。我想有一个高度等于其内容高度的滑动抽屉。 – Gratzi 2010-11-04 08:29:28