Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何以编程方式删除我的NestedScrollView的布局行为?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经在myCollapsingToolbarLayout中删除了layout_scrollFlags.但我需要删除我的nestedScrollView的layouT_Behavior,以便当我的嵌套滚动视图上没有内容时,工具栏的折叠也将被禁用.删除我的nestedScrollView的layouT_Behavior非常简单,我只是逐字地删除xml中的代码行,但是如何以编程方式删除它?

我的xml:

<android.support.design.widget.CoordinatorLayout
            xmlns:android="http://scheR_80_11845@as.android.com/apk/res/android"
            xmlns:app="http://scheR_80_11845@as.android.com/apk/res-auto"

            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                android:BACkground="@android:color/white">

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsing_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    app:contentScrim="?attr/colorPriMary"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">

                    <fragment
                        android:id="@+id/pawfile_header"
                        android:name="com.lightbulb.pawesome.fragments.PawfileHeaderFragment"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="10dp"
                        android:fitsSystemWindows="true"
                        app:layout_collapseMode="parallax" />

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

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

            <fragment
                android:id="@+id/pawfile_timeline"
                android:name="com.lightbulb.pawesome.user_timeline.PawesomeUserTimelineFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layouT_Behavior="@String/appbar_scrolling_view_behavior" />

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

解决方法

尝试从片段中删除“appbar_scrolling_view_behavior”并清除CollapsingToolbarLayout中的滚动标记
CoordinatorLayout.LayoutParams coordinatorLayoutParams = (CoordinatorLayout.LayoutParams) pawfileTimeline.getLayoutParams();
coordinatorLayoutParams.setBehavior(null);

AppBarLayout.LayoutParams toolbarLayoutParams = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
toolbarLayoutParams.setScrollFlags(0);

大佬总结

以上是大佬教程为你收集整理的android – 如何以编程方式删除我的NestedScrollView的布局行为?全部内容,希望文章能够帮你解决android – 如何以编程方式删除我的NestedScrollView的布局行为?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。