【发布时间】:2012-04-08 08:00:46
【问题描述】:
我有一个带有HorizontalScrollView 的布局,其中包含一个LinearLayout 的菜单,其中内容与数据库的内容一起膨胀。这可以正常工作,但是当没有足够的元素使HSV 滚动时,这不会填充理想情况下应该居中的屏幕宽度。 IE。
目前:
| Element 1 Element 2 | <- edge of screen
代替:
| Element 1 Element 2 | <- edge of screen
虽然仍然能够:
| Element 1 Element 2 Element 3 Element 4 Elem| <- edge of screen now scrolling
布局 XML 是:
<?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>
在 footerLayout 中扩展以下 XML:
<?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" />
【问题讨论】:
标签: android layout element center horizontalscrollview