这是我片段的xml代码。我能够在recyclerview上显示线性布局,但问题是,线性布局没有在屏幕底部对齐。 我应该使用相对布局而不是framelayout吗?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.dell.pollachiclient.MyCartFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_cart"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:background="#Fff"
>
<TextView
android:id="@+id/setup_macroSavebtn"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_gravity="start"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:textColor="#000"
android:background="#Fff"
android:textStyle="normal"
android:textSize="22sp"
android:text="$500.00"/>
<Button
android:id="@+id/setup_macroCancelbtn"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:gravity="center_vertical|center_horizontal"
android:layout_margin="10dp"
android:layout_weight="1"
android:textColor="#fff"
android:background="#FA631D"
android:text="Checkout"/>
</LinearLayout>
</FrameLayout>
答案 0 :(得分:0)
使用RelativeLayout
代替FrameLayout
并使用
android:layout_alignParentBottom="true"
在LinearLayout
中,您想要显示在底部。
答案 1 :(得分:0)
用户RelativeLayout并使用
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:background="#Fff"
android:layout_below="@id/recycler_view_cart"
>
答案 2 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
<Recycalvire
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/view_a" />
<View
android:id="@+id/view_a"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="@+id/bottom_layout"
android:background="@color/col1"></View>
<Linearlayout
layout="@layout/buttom_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
答案 3 :(得分:0)
请按@Nabin Bhandari的回答
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_cart"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_gravity="bottom"
android:background="#Fff"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<TextView
android:id="@+id/setup_macroSavebtn"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_gravity="start"
android:layout_weight="1"
android:background="#Fff"
android:gravity="center_vertical|center_horizontal"
android:text="$500.00"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="normal" />
<Button
android:id="@+id/setup_macroCancelbtn"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:background="#FA631D"
android:gravity="center_vertical|center_horizontal"
android:text="Checkout"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>