2011-01-19 32 views
5

Tôi đã đính kèm hình ảnh để minh họa rõ hơn những gì tôi đang làm.Bố cục Android: yếu tố vị trí bên dưới chế độ xem thấp nhất

Tôi có hai vị trí LinearLayout s được đặt cạnh nhau. Cả hai đều có thể mở rộng theo chiều dọc, sử dụng wrap_content. Tôi muốn vị trí một container (HorizontalScrollView) dưới đây nào có một chiều cao lớn hơn. Nó hiện được thiết lập để đi bên dưới cột ngoài cùng bên phải, nói chung nó cao hơn, nhưng trong một số trường hợp, ScrollView sẽ bao phủ nội dung ở cột ngoài cùng bên trái. Có cách nào để thiết lập này trong tập tin .xml hoặc tôi sẽ cần phải nghỉ mát để thiết lập này trong phương pháp onCreate của tôi?

Example screen

Trả lời

3

Bạn có thể quấn lại với nhau hai LinearLayouts trong một tuyến tính hoặc bố trí tương đối, một cái gì đó như thế (chỉ cần thay đổi các thuộc tính cho bản gốc 3 bố trí là bạn có/cần họ):

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
android:id="@+id/parent" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 
<RelativeLayout 
android:id="@+id/frame" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentTop="true" 
> 
<LinearLayout 
android:id="@+id/linearLeft" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:layout_alignParentTop="true" 
android:layout_alignParentLeft="true" 
android:layout_toLeftOf="@+id/linearRight" 
> 
</LinearLayout> 
<LinearLayout 
android:id="@+id/linearRight" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:layout_alignParentTop="true" 
android:layout_alignParentRight="true" 
> 
</LinearLayout> 
</RelativeLayout> 
<ScrollView 
android:id="@+id/scroll" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_below="@+id/frame" 
android:layout_alignParentLeft="true" 
> 
</ScrollView> 
</RelativeLayout> 
+0

tôi đã kết thúc sử dụng này giải pháp, nhưng cả hai đều đã làm việc. – Taka

1

Tôi muốn vị trí khác container (HorizontalScrollView) dưới đây bất cứ ai có chiều cao lớn hơn.

Bạn phải đặt chương trình theo phương pháp theo phương pháp onConfigurationChanged. Vì vậy, nó có thể hoạt động đúng sau khi thay đổi hướng của thiết bị.

Các vấn đề liên quan