Tôi có ngăn kéo thanh trượt trong ứng dụng của mình. Nếu tôi đặt wrap_content làm giá trị cho trường layout_height, ngăn kéo thanh trượt sẽ kéo dài trên toàn bộ màn hình. Sử dụng một hằng số như chiều cao cũng không phải là một lựa chọn tốt. Có thể có ngăn kéo thanh trượt với chiều cao của nội dung không?Đặt chiều cao ngăn trượt thanh trượt
Cảm ơn trước!
<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>
Đó là FrameLayout. Tôi đã thay đổi nó thành LinearLayout và thiết lập các trọng số. Nhưng cũng vậy. – Gratzi
Bạn có thể đăng bố cục không? – EboMike
Tôi đã đăng nó trong câu hỏi ban đầu. Tôi đã làm một số sửa chữa và kết luận cuối cùng là nếu tôi thiết lập các trọng số để 1 cho xem giả và ngăn kéo, cả hai người trong số họ sẽ có chiều cao bằng 1/2 của màn hình. Tôi muốn có một ngăn kéo trượt với chiều cao bằng với chiều cao nội dung của nó. – Gratzi