Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Coordinator布局底部栏隐藏在列表视图中_Android_Android Layout_Android Coordinatorlayout - Fatal编程技术网

Android Coordinator布局底部栏隐藏在列表视图中

Android Coordinator布局底部栏隐藏在列表视图中,android,android-layout,android-coordinatorlayout,Android,Android Layout,Android Coordinatorlayout,底部按钮/某些视图隐藏列表视图底部部分 <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/t

底部按钮/某些视图隐藏列表视图底部部分

  <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.support.design.widget.AppBarLayout>

         <android.support.v4.widget.NestedScrollView 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:context="example.design.activities.DetailsActivity"
                android:background="@color/grey">

                <android.support.v7.widget.RecyclerView
                    android:paddingTop="80dp"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>


            </android.support.v4.widget.NestedScrollView>


        <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="bottom"
                android:gravity="bottom">

                <!-- Add to cart button -->
                <android.support.v7.widget.AppCompatButton
                    android:id="@+id/ssssss"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:padding="20dp"
                    android:text="ADD TO CART"
                    android:backgroundTint="@color/colorPrimary"
                    android:textColor="@color/white"
                    android:layout_alignParentBottom="true"
                    android:visibility="visible" />

            </RelativeLayout>

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

我将根据条件使底部视图可见和不可见


如果底部栏可见,如何调整列表视图以进行更多滚动?

您可以在嵌套的滚动视图中添加
android:cliptoppadding=“false”
。 当您显示底部按钮时,可以为NestedScrollview动态添加底部填充,其值等于底部按钮的高度

nestedScrollView.setPadding(yourPadding, yourPadding,yourPadding, btn.getMeasuredHeight())

您可以在NestedScrollView中添加android:clipToPadding=“false”
。 当您显示底部按钮时,可以为NestedScrollview动态添加底部填充,其值等于底部按钮的高度

nestedScrollView.setPadding(yourPadding, yourPadding,yourPadding, btn.getMeasuredHeight())

您应该使用布局锚来更改NestedScrollView,如下所示

<android.support.v4.widget.NestedScrollView 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:context="example.design.activities.DetailsActivity"
    android:background="@color/colorPrimary"
    app:layout_anchor="@+id/relative_view"
    app:layout_anchorGravity="top">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:paddingTop="80dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


</android.support.v4.widget.NestedScrollView>


它会根据您的外观将scrollview放在底部栏的顶部。

您应该使用布局锚更改NestedScrollView,如下所示

<android.support.v4.widget.NestedScrollView 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:context="example.design.activities.DetailsActivity"
    android:background="@color/colorPrimary"
    app:layout_anchor="@+id/relative_view"
    app:layout_anchorGravity="top">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:paddingTop="80dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


</android.support.v4.widget.NestedScrollView>


它会根据您的外貌将scrollview置于底部栏的顶部。

我认为这会解决您的问题

 <?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fillViewport="true"
        android:background="@android:color/darker_gray">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_alignParentTop="true"
                android:layout_height="match_parent"
                android:layout_above="@+id/ssssss"/>

            <!-- Add to cart button -->
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/ssssss"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="20dp"
                android:text="ADD TO CART"
                android:layout_alignParentBottom="true"
                android:backgroundTint="@color/colorPrimary"
                android:textColor="@android:color/white"

                android:visibility="visible" />

        </RelativeLayout>


    </android.support.v4.widget.NestedScrollView>




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

注: 您已经添加了
android:fitsystemwindows=“true”
,因此您需要在您的回收器视图中添加
android:paddingTop=“80dp”
。相反,您可以按照我的解决方案中的操作,只需将
android:fillViewport=“true”
添加到nestedScrollView,而无需对回收器视图进行填充。
我希望这能解决你的问题

我想这能解决你的问题

 <?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fillViewport="true"
        android:background="@android:color/darker_gray">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_alignParentTop="true"
                android:layout_height="match_parent"
                android:layout_above="@+id/ssssss"/>

            <!-- Add to cart button -->
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/ssssss"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="20dp"
                android:text="ADD TO CART"
                android:layout_alignParentBottom="true"
                android:backgroundTint="@color/colorPrimary"
                android:textColor="@android:color/white"

                android:visibility="visible" />

        </RelativeLayout>


    </android.support.v4.widget.NestedScrollView>




</android.support.design.widget.CoordinatorLayout>
<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.v4.widget.NestedScrollView 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:background="#EAEAEA"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context="example.design.activities.DetailsActivity">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <!-- Add to cart button -->
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/ssssss"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:backgroundTint="@color/colorPrimary"
                android:padding="20dp"
                android:text="ADD TO CART"
                android:textColor="#FFFFFF"
                android:visibility="visible" />

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/ssssss"
                android:layout_alignParentTop="true"
                android:paddingTop="80dp" />
        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>


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

注: 您已经添加了
android:fitsystemwindows=“true”
,因此您需要在您的回收器视图中添加
android:paddingTop=“80dp”
。相反,您可以按照我的解决方案中的操作,只需将
android:fillViewport=“true”
添加到nestedScrollView,而无需对回收器视图进行填充。 我希望这能解决您的问题


<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.v4.widget.NestedScrollView 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:background="#EAEAEA"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context="example.design.activities.DetailsActivity">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <!-- Add to cart button -->
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/ssssss"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:backgroundTint="@color/colorPrimary"
                android:padding="20dp"
                android:text="ADD TO CART"
                android:textColor="#FFFFFF"
                android:visibility="visible" />

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/ssssss"
                android:layout_alignParentTop="true"
                android:paddingTop="80dp" />
        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>


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



您能描述更多吗?我有一个菜单项列表,一旦用户选择了菜单项,我会将一个按钮标记为可见。此图显示可见按钮。此时,列表视图的最后一个元素隐藏在按钮后面。我想让它在顶部/滚动更多。你检查过了吗。是的,我添加了app:layout_anchor=“@+id/post_text_layout”和app:layout_anchorGravity=“bottom”。还藏着。滚动视图在appbar之外。您能描述更多吗?我有一个菜单项列表,一旦用户选择了这些项,我会将一个按钮标记为可见。此图显示可见按钮。此时,列表视图的最后一个元素隐藏在按钮后面。我想让它在顶部/滚动更多。你检查过了吗。是的,我添加了app:layout_anchor=“@+id/post_text_layout”和app:layout_anchorGravity=“bottom”。还藏着。滚动视图位于appbar外部。如果添加此视图,则顶部折叠工具栏视图将产生闪烁效果。向上滚动后。如果添加此选项,则顶部折叠工具栏视图将显示闪烁效果。向上滚动后,此视图将显示在列表下哪一个底部视图?没有,因为两者都在相对布局内是的,我试过了。它不在名单之内。这是唯一的列表下面。你可以继续尝试:)@RoshanA我已经附上了示例输出,因为你可以看到这一个不在我添加的列表下面。但是在最后一项之下。可能是什么?应始终位于屏幕底部。此视图将位于列表下哪个底部视图?没有,因为两者都在相对布局内是的,我试过了。它不在名单之内。这是唯一的列表下面。你可以继续尝试:)@RoshanA我已经附上了示例输出,因为你可以看到这一个不在我添加的列表下面。但是在最后一项之下。可能是什么?应始终位于屏幕底部。hi getMeasuredHeight返回0?唯一的问题是获取高度。rest正常。hi getMeasuredHeight返回0?唯一的问题是获取高度。休息很好。