gpt4 book ai didi

android - 未应用布局重力底部

转载 作者:行者123 更新时间:2023-11-29 18:48:30 25 4
gpt4 key购买 nike

下面是我的 xml 文件,我希望 linearlayout 位于底部,即布局重力底部。但它不起作用。

即使查看了针对此类问题给出的所有解决方案,我也无法解决它。请帮忙

<?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">

<include layout="@layout/toolbar_layout" />

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" //----> not working
android:orientation="horizontal">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/total"
android:textStyle="bold" />

<TextView
android:id="@+id/textViewTotalPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$23.00" />
</LinearLayout>

<Button
android:id="@+id/buttonCheckout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:drawableEnd="@drawable/ic_arrow_forward"
android:paddingEnd="15dp"
android:text="@string/checkout"
android:textColor="@color/white" />
</LinearLayout>

这就是我想要的方式。

enter image description here

最佳答案

试试这个

   <?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">

<include layout="@layout/toolbar_layout" />

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewCart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="total"
android:textStyle="bold" />

<TextView
android:id="@+id/textViewTotalPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$23.00" />
</LinearLayout>

<Button
android:id="@+id/buttonCheckout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="20dp"
android:background="@color/colorPrimary"
android:drawableEnd="@drawable/ic_arrow_forward"
android:paddingEnd="15dp"
android:text="@string/checkout"
android:textColor="@color/white" />


</LinearLayout>

</LinearLayout>

关于android - 未应用布局重力底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51305990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com