Hel*_*esh 10 android relativelayout android-layout android-recyclerview
我需要在RecyclerView下面添加一个RelativeLayout,并且能够这样做,除了TOTAL(R.id.total_amount_tv)下的按钮没有显示:
我可以轻松滚动项目,它不会影响我的RelativeLayout.我只需要按钮就可以看到.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/order_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/total_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="@string/total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/total_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/total_tv"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/total_amount_tv"
android:layout_marginTop="51dp"
android:background="@color/accent"
android:onClick="onClickSendOrder"
android:text="@string/order_btn"
android:textColor="@android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
您需要将屏幕划分为两个部分,以显示Recyclerview,其他部分用于RelativeLayout
<LinearLayout
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"
android:background="@android:color/white"
android:orientation="vertical"
android:weightSum="10">
<android.support.v7.widget.RecyclerView
android:id="@+id/order_recycler"
android:layout_weight = "8.5"
android:layout_width="match_parent"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_weight = "1.5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/total_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/total_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/total_tv"
android:textSize="20sp"
android:text="Total Right"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="@android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这将产生以下结果
| 归档时间: |
|
| 查看次数: |
8920 次 |
| 最近记录: |