Android 父嵌套滚动视图禁用所有功能
因此,我的活动布局如下:Android 父嵌套滚动视图禁用所有功能,android,android-coordinatorlayout,android-nestedscrollview,Android,Android Coordinatorlayout,Android 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:id="@+id/mai
<?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:id="@+id/main_activity_root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/main_activity_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main_activity_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/actionBarSize">
<include layout="@layout/include_toolbar" />
</android.support.design.widget.CollapsingToolbarLayout>
<LinearLayout
android:id="@+id/below_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/actionBarSize"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/main_activity_sub_category_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/layout_margin_list"
android:gravity="start|center_vertical"
android:textColor="@color/white"
android:textSize="@dimen/text_bigger" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/main_activity_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/main_activity_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<vb.uzoni.ui.view.BottomMenuView
android:id="@+id/main_activity_bottom_menu_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/actionBarSize"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/single_message_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</LinearLayout>
在预览窗口中,它如下所示:
<?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:id="@+id/main_activity_root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/main_activity_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main_activity_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/actionBarSize">
<include layout="@layout/include_toolbar" />
</android.support.design.widget.CollapsingToolbarLayout>
<LinearLayout
android:id="@+id/below_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/actionBarSize"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/main_activity_sub_category_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/layout_margin_list"
android:gravity="start|center_vertical"
android:textColor="@color/white"
android:textSize="@dimen/text_bigger" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/main_activity_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/main_activity_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<vb.uzoni.ui.view.BottomMenuView
android:id="@+id/main_activity_bottom_menu_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/actionBarSize"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/single_message_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</LinearLayout>
但实际上,它使用NestedScrollView
作为父视图,并将我的EditText
和按钮
推到NestedScrollView
的底部
接下来我想做的是:
1.禁用从NestedScrollView
2.我不想继承NestedScrollView
的可滚动功能,这样我就可以将我的按钮
和EditText
放在视图的底部,使它们始终可见
这怎么可能
编辑
现在,片段中的嵌套滚动视图出现问题:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/sub_categories_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/homeDividerColor" />
</android.support.v4.widget.NestedScrollView>
它不显示回收器视图,也不执行应用程序滚动行为…无需使用
NestedScrollView
。相反,您可以使用-
<FrameLayout
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- Replace your fragment in this container -->
<FrameLayout
android:id="@+id/main_activity_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/main_activity_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
看起来,我消除了您的
NestedScrollView
问题您可以尝试将NestedScrollView
放入Framelayout
容器中。并动态替换容器
它将消除Nestedscrollview
滚动问题
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_activity_root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_activity_fragment_container"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<--Your contents-->
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
我需要NestedScroll视图,因为在某些片段中,我具有与AppBar滚动行为相匹配的功能…请尝试将可滚动内容(如NestedScrollView
或recyclerview
)放在片段中。并将app:layou\u behavior
也放在可滚动的视图中。它不起作用,因为我在app bar下面有FrameLayout和BottomMenuView..Ta da。。我告诉过你;-)是的,现在还有一个问题…:)当我在片段布局中放置“NestedScrollView”时,它不会显示回收器视图。请参见编辑后的问题