Tôi có một bố trí với một HorizontalScrollView
có chứa một LinearLayout
cho một Menu nơi nội dung được thổi phồng với nội dung của DB. Điều này hoạt động tốt tuy nhiên khi không có đủ yếu tố để làm cho di chuyển HSV
này không điền vào chiều rộng của màn hình lý tưởng nên được làm trung tâm. tức là Hiện tại:Trung tâm elemets của HorizontalScrollView khi không đủ để làm cho nó cuộn
| Element 1 Element 2 | <- edge of screen
Thay vì:
| Element 1 Element 2 | <- edge of screen
trong khi vẫn có thể:
| Element 1 Element 2 Element 3 Element 4 Elem| <- edge of screen now scrolling
Cách bố trí XML là:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLinearLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="25dp" >
</TextView>
<ScrollView
android:id="@+id/scroll1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/contentLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="30dp">
<LinearLayout
android:id="@+id/footerLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
Với XML sau đang phồng lên ed inside footerLayout:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer_content"
android:textSize="18sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="FOOTER"
android:singleLine="true" />
Mọi trợ giúp sẽ được đánh giá cao.
không có tác dụng, vẫn có vẻ giống nhau – Alasdair
nó có vẻ như các LinearLayout footerLayout không mở rộng để lấp đầy toàn bộ chiều rộng nếu chỉ có một hoặc hai yếu tố này là bên trong. – Alasdair
thử một điều nữa có thể là nó hoạt động gán tổng wieght cho linearlayout trong mã ur cho bất kỳ số lượng phần tử nào mà ur chèn và gán wieght 1 trong xml cho textView được tăng cao. –