【问题标题】:How do I fix a layout inside Coordinator Layout?如何修复 Coordinator Layout 中的布局?
【发布时间】:2015-12-15 11:33:05
【问题描述】:

当前回收站视图和应用栏滚动。现在我需要将相对布局 rlProductCheckout 固定到屏幕底部,即使 recyclerview 和应用栏滚动也是如此。当我开始滚动时,当前的相对布局会消失,只有当我移回列表的开头时才会重新出现。

content_products_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_products_list">



    <android.support.v7.widget.RecyclerView
        android:id="@+id/rvProductList"
        android:layout_above="@+id/rlProductCheckout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:gravity="center_vertical"
        android:id="@+id/rlProductCheckout"
        android:layout_alignParentBottom="true">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Checkout"/>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_send"
            android:layout_alignParentRight="true"/>

    </RelativeLayout>
</RelativeLayout>

activity_products_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/expandedImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@mipmap/prod1"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />


        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

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



</android.support.design.widget.CoordinatorLayout>

【问题讨论】:

    标签: android material-design android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout


    【解决方案1】:

    尝试将RelativeLayout 包裹在CoordinatorLayout 之外。试试这样的How to put RelativeLayout inside CoordinatorLayout

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      • 2018-11-29
      • 2021-07-22
      • 1970-01-01
      相关资源
      最近更新 更多