我的布局有问题,我需要在底部



我正在使用线性布局作为父布局,并且需要在页面底部使用线性布局作为按钮。

我现在所能使用的只是线性布局的边距顶部,这不是正确的方法。所以我需要帮助来实现屏幕底部的布局。

或者我需要使用哪种布局以获得所需结果的任何建议。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F0F0F0">
<LinearLayout
android:layout_margin="10dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textColor="#000000"
android:text="Customer contact details:"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Name:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Email:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="user@gmail.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Mobile:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="123456"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="DELIVERY TYPE"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="10dp"
android:id="@+id/text"
android:layout_marginStart="20dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the delivery 
address."
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Pickup"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/pickup_time"
android:text="Select pickup time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:background="#D3D3D3"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="Delivery"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/delivery_time"
android:text="Select delivery time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
android:textColor="#000000"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:id="@+id/payment_option"
android:text="PAYMENT OPTION"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_marginStart="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="Pay Online"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:weightSum="1"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Button
android:layout_marginEnd="10dp"
android:padding="10dp"
android:id="@+id/add_address"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:background="@drawable/button_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="2dp"/>
<TextView
android:text="Home"
android:textColor="#000000"
android:layout_marginStart="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:textColor="#000000"
android:layout_marginStart="30dp"
android:text="User Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:padding="10dp"
android:weightSum="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E22028">
<TextView
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FFFFFF"
android:text="Continue"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ImageView
android:src="@drawable/ic_navigate_next_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

对于如此复杂的视图,您应该始终使用约束布局。他们真的很方便.

您需要注意的事情很少,因为从您的代码中我可以看到很多硬编码文本和硬币,这对任何Android开发人员来说都是不好的做法。甚至命名约定也应该看看.

这里是我们应该长期遵循的命名约定准则 安卓 . https://github.com/ribot/android-guidelines/blob/master/project_and_code_guidelines.md

对于约束布局,您可以使用以下链接来更好地理解。


https://android-developers.googleblog.com/2017/08/understanding-performance-benefits-of.html https://blog.mindorks.com/android-constraint-layout

始终尝试将一角硬币放在一角硬币.xml文件夹中的res下。Res<值><dimens。>

现在来回答您的问题,我们可以使用约束布局来做到这一点

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/constraint_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0"
android:orientation="vertical">

<LinearLayout
android:id="@+id/linear_customer_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical"
android:padding="10dp"
app:layout_constraintEnd_toEndOf="@id/constraint_parent"
app:layout_constraintStart_toStartOf="@id/constraint_parent"
app:layout_constraintTop_toTopOf="@id/constraint_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Customer contact details:"
android:textColor="#000000" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Email:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="user@gmail.com" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mobile:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="123456" />
</TableRow>
</TableLayout>
</LinearLayout>

<TextView
android:id="@+id/text_delivery_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:text="DELIVERY TYPE"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="@id/constraint_parent"
app:layout_constraintStart_toStartOf="@id/constraint_parent"
app:layout_constraintTop_toBottomOf="@+id/linear_customer_detail" />
<TextView
android:id="@+id/text_delivery_note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the delivery
address."
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="@id/text_delivery_type"
app:layout_constraintStart_toStartOf="@+id/text_delivery_type"
app:layout_constraintTop_toBottomOf="@+id/text_delivery_type" />
<LinearLayout
android:id="@+id/linear_pickup_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingTop="5dp"
app:layout_constraintEnd_toEndOf="@id/constraint_parent"
app:layout_constraintStart_toStartOf="@id/constraint_parent"
app:layout_constraintTop_toBottomOf="@+id/text_delivery_note">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pickup"
android:textColor="#000000" />
<TextView
android:id="@+id/pickup_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select pickup time"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#D3D3D3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:text="Delivery"
android:textColor="#000000" />
<TextView
android:id="@+id/delivery_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select delivery time"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="@+id/payment_option"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="PAYMENT OPTION"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="@id/text_delivery_type"
app:layout_constraintStart_toStartOf="@id/text_delivery_type"
app:layout_constraintTop_toBottomOf="@+id/linear_pickup_view" />
<LinearLayout
android:id="@+id/linear_pay_online"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:paddingTop="5dp"
android:paddingBottom="5dp"
app:layout_constraintEnd_toEndOf="@id/constraint_parent"
app:layout_constraintStart_toStartOf="@id/constraint_parent"
app:layout_constraintTop_toBottomOf="@+id/payment_option">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pay Online" />
</LinearLayout>

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="@id/add_address"
app:layout_constraintStart_toStartOf="@id/text_delivery_type"
app:layout_constraintTop_toTopOf="@id/add_address" />
<Button
android:id="@+id/add_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/button_red"
android:padding="10dp"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF"
app:layout_constraintEnd_toEndOf="@id/text_delivery_type"
app:layout_constraintTop_toBottomOf="@+id/linear_pay_online" />

<View
android:id="@+id/view_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="@id/constraint_parent"
app:layout_constraintStart_toStartOf="@id/constraint_parent"
app:layout_constraintTop_toBottomOf="@id/add_address" />
<TextView
android:id="@+id/text_home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Home"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="@id/text_delivery_type"
app:layout_constraintStart_toStartOf="@id/text_delivery_type"
app:layout_constraintTop_toBottomOf="@id/view_divider" />
<TextView
android:id="@+id/text_user_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="User Address"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="@id/text_home"
app:layout_constraintStart_toStartOf="@id/text_home"
app:layout_constraintTop_toBottomOf="@+id/text_home" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E22028"
android:padding="10dp"
android:weightSum="1"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Continue"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_navigate_next_black_24dp" />
</LinearLayout>

希望这会有所帮助.快乐编码。

您可以在LinearLayout中使用间隔条视图

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F0F0F0">
<!-- Top View -->
<View
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- Vertical Spacer -->
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<!-- Bottom View -->
<View
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

垂直间隔条将填充顶部视图和底部视图之间的屏幕。

试试这个:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0">
<!-- You can also use a button with 'android:drawableEnd="@drawable/ic_navigate_next_black_24dp" -->
<!-- instead of this LinearLayout'-->
<LinearLayout
android:id="@+id/layout_bottom_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#E22028"
android:gravity="center"
android:padding="10dp"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Continue"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_navigate_next_black_24dp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/layout_bottom_btn"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F0F0F0"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Customer contact details:"
android:textColor="#000000" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Email:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="user@gmail.com" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mobile:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="123456" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="DELIVERY TYPE"
android:textColor="#000000" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the deliveryaddress."
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingTop="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pickup"
android:textColor="#000000" />
<TextView
android:id="@+id/pickup_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select pickup time"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#D3D3D3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:text="Delivery"
android:textColor="#000000" />
<TextView
android:id="@+id/delivery_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select delivery time"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="@+id/payment_option"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="PAYMENT OPTION"
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pay Online" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000" />
<Button
android:id="@+id/add_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="@drawable/button_red"
android:padding="10dp"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:background="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:text="Home"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:text="User Address"
android:textColor="#000000" />
</LinearLayout>
</ScrollView>
</RelativeLayout>

我在您的布局中使用了RelativeLayout作为父级,正如 Tim Castelijns 评论的那样,是的,您必须使用ConstraintLayout以获得更好、响应迅速的用户界面。

您的布局有太多的层次结构元素,请改用约束布局,但是在 LinearLayout 中,您可以添加权重为 1 和高度为 0 的视图,就像我在布局中添加的那样

**<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F0F0F0">
<LinearLayout
android:layout_margin="10dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textColor="#000000"
android:text="Customer contact details:"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Name:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Email:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="user@gmail.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Mobile:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="123456"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="DELIVERY TYPE"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="10dp"
android:id="@+id/text"
android:layout_marginStart="20dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the delivery 
address."
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Pickup"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/pickup_time"
android:text="Select pickup time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:background="#D3D3D3"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="Delivery"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/delivery_time"
android:text="Select delivery time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
android:textColor="#000000"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:id="@+id/payment_option"
android:text="PAYMENT OPTION"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_marginStart="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="Pay Online"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:weightSum="1"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Button
android:layout_marginEnd="10dp"
android:padding="10dp"
android:id="@+id/add_address"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:background="@drawable/button_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="2dp"/>
<TextView
android:text="Home"
android:textColor="#000000"
android:layout_marginStart="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:textColor="#000000"
android:layout_marginStart="30dp"
android:text="User Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:padding="10dp"
android:weightSum="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E22028">
<TextView
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FFFFFF"
android:text="Continue"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ImageView
android:src="@drawable/ic_navigate_next_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>**

将LinearLayout 替换为相对布局并创建子父级线性布局并将视图放入其中,然后使其对齐父底部 确保您已指定子父级布局高度以包装内容

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--put your layout inside it-->
</LinearLayout>

最新更新