为什么滚动视图中的线性布局不适合屏幕尺寸?我试图对"Layout_Height"进行一些更改,但没有成功。
这是我的XML代码:谢谢你的帮助!
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollViewPhysicalExam"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/HeaderText"
android:orientation="vertical" >
<!-- ++++++++++++++++++ Row18 ++++++++++++++++++ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnBack"
android:text="@string/Back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.00"
android:textSize="15dip" />
<Button
android:id="@+id/btnSave"
android:text="Save"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.00"
android:textSize="15dip" />
</LinearLayout>
<!-- +++++++++++++++++++++++++++++++++++++++++++ -->
</LinearLayout>
</LinearLayout>
</ScrollView>
我不能评论,所以我试着回答:您是否尝试在ScrollView
中设置android:fillViewport="true"
?
1)为什么你将LinearLayout
嵌套在LinearLayout
内另一个LinearLayout
内?我只能假设这只是xml文件的摘录,否则这就没有任何意义了。
2)你到底遇到了什么问题?LinearLayout
太长,以至于它在底部留下可见的屏幕?如果是这样,那是因为ScrollView
是父元素。通过设置android:layout_height="match_parent"
, ScrollView
将填充屏幕。ScrollView
本身为它的子视图提供了一个无限的高度空间,所以在子视图(LinearLayout
)中设置android:layout_height="match_parent"
也会使它占用无限的空间。您应该将其设置为android:layout_height="wrap_content"
,看看是否适合您!