我的布局有问题,这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/Scroll"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableLayout
android:id="@+id/Table"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/BookingStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/BookingBtn"
android:src="@drawable/statusbarcomplete"/>
<Button
android:id="@+id/BookingBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/Red"
android:text="Place My Booking"
android:textAllCaps="true"
android:textColor="@color/White"
android:textStyle="bold"/>
</RelativeLayout>
</RelativeLayout>
这是在小型设备上的外观:
这是在大型设备上的外观
现在您可以看到问题出在小型设备上,按钮和图像似乎在布局的顶部“浮动”,而我一直希望它们在布局的底部。因此,用户将需要在小型设备上滚动,但是图像会一直显示在底部,底部的按钮将始终在底部,并且始终可见!滚动视图将占据屏幕的其余部分,以便用户可以看到信息。
您可以在此处查看xml文件的完整代码。我删除了所有表行以保持该线程整齐,并且因为代码超过300行
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<ScrollView
android:id="@+id/Scroll"
android:layout_above="@+id/relative"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:orientation="vertical" >
<TableLayout
android:id="@+id/Table"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TableLayout>
</ScrollView>
<LinearLayout
android:id="@+id/relative"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true" >
<ImageView
android:id="@+id/BookingStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/BookingBtn" />
<Button
android:id="@+id/BookingBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@color/Red"
android:text="Place My Booking"
android:textAllCaps="true"
android:textColor="@color/White"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
试试这个。只需将滚动视图放在包含图像和按钮的相对布局上方即可。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句