标签: nestedscrollview

当EditText获得焦点时,使用TextInputLayout滚动NestedScrollView

我有那种布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/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:background="@color/appbar_background">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="360dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:elevation="1dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:titleEnabled="false">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7">

                <android.support.v4.view.ViewPager
                    android:id="@+id/post_pager"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                />

            </RelativeLayout>

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


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


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:background="@color/common_green"
        android:src="@drawable/add_picture"
        app:backgroundTint="@color/common_green"
        app:elevation="2dp"
        app:fabSize="normal"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|left|start"
        app:rippleColor="@color/common_grey"/>


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:fitsSystemWindows="true"
        android:padding="16dp"
        app:elevation="5dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <android.support.design.widget.TextInputLayout
                android:id="@+id/slide_content_til"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:background="@color/appbar_background"
                android:hint="@string/write_something"
                android:orientation="vertical"
                android:textColorHint="@color/white"
                app:errorEnabled="false" …
Run Code Online (Sandbox Code Playgroud)

android nestedscrollview textinputlayout

6
推荐指数
0
解决办法
1181
查看次数

处理RecyclerView,NestedScrollView和CardView

我将在我的应用程序中实现此UI: UI

好吧,我之前尝试过的一些方法:

1.使用CollapsingToolbarLayout 我把我CardView的insid CollapsingToolbarLayout并把他们都在AppBarLAyout.

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|exitUntilCollapsed" >

            <CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />
                  <!-- My Views Goes there -->
            </CardView

            <android.support.v7.widget.Toolbar
                android:id="@+id/flexible.example.toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@null"
                app:layout_collapseMode="pin"
                style="@style/ToolBarWithNavigationBack"
                />
        </android.support.design.widget.CollapsingToolbarLayout>

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

    <RecyclerView
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
    ></RecyclerView>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

PS:我删除了不相关的代码,不提我

这种方式正常但是!!! 当CardView高度高于屏幕高度时,它的内容由AppBarLayout用户显示并且不向用户显示

2.使用NestedScrollView 我放入CardViewRecyclerView内部NestedScrollView.但问题是当用户到达时回收到RecyclerView,然后滚动回到顶部,fling会变得迟钝和错误并停止一些用户必须滚动越来越多的地方!

<android.support.v4.widget.NestedScrollView
    android:id="@+id/nested_scrollbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="fill_vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:scrollbars="none" >
        <LinearLayout
            android:id="@+id/nested_scrollbar_linear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

                <android.support.v7.widget.CardView
                    android:id="@+id/flexible.example.cardview"
                    android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-collapsingtoolbarlayout android-appbarlayout nestedscrollview

6
推荐指数
1
解决办法
6586
查看次数

滚动到包含 NestedScrollView 和 AppBarLayout 的 CoordinatorLayout 的底部

有没有办法(以编程方式或通过 xml)滚动到以下 CoordinatorLayout 的底部(见下文),以便在显示屏幕时可以看到 NestedScrollView 中的最后一个元素?

附件是显示的实际屏幕和想要显示的屏幕。您可以注意到比较两个图像,向下滚动时,图像具有视差效果。

我希望当屏幕加载时,NestedScrollView 底部的按钮(仅在第二张图片中可见)是可见的......只需要一点点自动滚动!

任何建议将不胜感激。

当前显示的初始屏幕:

当前显示的初始屏幕

所需的初始屏幕:

所需的初始屏幕

布局的xml:

<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.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:background="#000"
                android:paddingEnd="40dp"
                android:paddingStart="40dp"
                android:paddingTop="30dp"
                android:src="@drawable/image"
                app:layout_collapseMode="parallax"
                tools:ignore="ContentDescription"/>

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

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:paddingBottom="30dp"
            android:paddingTop="30dp">

            <TextView
                style="@style/register_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/register_text_1"/>

            <EditText
                android:id="@+id/param1"
                style="@style/register_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/param1"
                android:textColorHint="#fff"/>

            <EditText
                android:id="@+id/param2"
                style="@style/register_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/param2"
                android:textColorHint="#fff"/>

            <EditText
                android:id="@+id/param3"
                style="@style/register_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/param3"
                android:textColorHint="#fff"/>

            <EditText
                android:id="@+id/param4" …
Run Code Online (Sandbox Code Playgroud)

android parallax android-coordinatorlayout android-appbarlayout nestedscrollview

6
推荐指数
0
解决办法
766
查看次数

Twitter个人资料页面iOS Swift剖析(UIScrollView中有多个UITableViews)

在此处输入图片说明

嗨...他们实际上是如何实现的?Twitter个人资料页面有一些教程。但是它们无法处理所有可能性...首先...当您在任何位置滚动顶部或底部时,顶视图开始滚动,直到分段控件到达页面顶部...然后滚动不会停止并且无法进行子表化开始滚动直到触及中途并且tableview中途开始动态加载其他行...所以我不认为它们静态设置了scrollview的内容

第二件事,他们如何处理子表...它们是containerView吗?如果是这样,那么结构将像这样

ScrollView
  TopView (User Info)
  Segmented Controll
  scrollView(to swipe right or left changing tables)
     ContainerView For  TWEETS
     ContainerView For  TWEETS & REPLIES
     ContainerView For  MEDIA
     ContainerView For  LIKES
Run Code Online (Sandbox Code Playgroud)

我对吗?因此,他们如何处理子表和“顶滚动视图”之间的滚动以实现基于滚动的顶视图位置更改...

令人不寒而栗

这就是我如何处理嵌套的ScrollViews ...我制作了childDidScroll协议,并且我的子tableviews实现了这一点,在我的个人资料页面中,我可以在childDidScroll方法中接收所有子didscroll事件:

   //if child scrollview going up
if(scrollView.panGestureRecognizer.translation(in: scrollView.superview).y > 0)
        {
            //check top scrollview if it is at bottom or top
            //then disable the current scrollview
            if mainScrollView.isAtBottom && scrollView.isAtTop{
                scrollView.isScrollEnabled = false
            }else{
                //else enable scrolling for my childs
                featuresVC.tableView!.isScrollEnabled = true
                categoriesVC.tableView!.isScrollEnabled = true
                shopsVC.tableView!.isScrollEnabled = …
Run Code Online (Sandbox Code Playgroud)

ios swift nestedscrollview

6
推荐指数
2
解决办法
1738
查看次数

如何在 DraggableScrollableSheet 中添加带有固定标题的可滚动选项卡?

我正在尝试将 aNestedScrollView用于a中的可滚动选项卡,DraggableScrollableSheet并且需要将工作表的控制器传递给NestedScrollViews 的可滚动正文,但是这样做不受支持,NestedScrollView这要求内部滚动项隐式使用上下文的PrimaryScrollController.

由此产生的行为是,我看到:

  1. 可拖动工作表的行为是正确的,并且工作表在滚动前向上移动,但滚动后不会应用标题的高度,标题也不会响应拖动事件(下面的“Foo”选项卡),或者;
  2. 与上述相反 - 工作表不响应拖动事件,但正确应用了标题的高度并且标题本身正确响应滚动手势(下面的“栏”选项卡)

Screen-Recording-2020-12-06-at-5.35.01-pm.gif

我已经尝试的多种组合NestedScrollViewCustomScrollViewTabView,尝试添加控制器全部,一些没有scrollables的。没运气。我什至尝试Notification从任何一个附加的可滚动对象中监听事件,并用这些事件更新另一个,以尝试使它们保持同步。纳达。

非常感谢这方面的任何帮助,我已经把头发扯了一段时间了。谢谢!

这是main.dart上面视频中的代码:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) …
Run Code Online (Sandbox Code Playgroud)

tabs nestedscrollview flutter

6
推荐指数
0
解决办法
171
查看次数

Android:检查 NestedScrollView 是在底部还是顶部

我正在使用 NestedScrollView,我想检查 NestedScrollView 是在底部还是顶部 :-)

有什么建议?谢谢!

android nestedscrollview

5
推荐指数
1
解决办法
4087
查看次数

如何使用滚动条和快速滚动到NestedScrollView

我正在使用带有Coordinator布局的NestedScrollView.

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

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <...AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:toolbarId="@+id/toolbar"
            app:contentScrim="@color/my_primary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

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

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

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

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <FrameLayout
            android:id="@+id/frame_layout_2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我想添加一个滚动条来使用它拖动滚动视图(快速滚动).看起来NestedScrollView没有fastScroll属性.

我尝试添加

    android:scrollbars="vertical"
    android:fadeScrollbars="false"
    android:fastScrollEnabled="true"
    android:fastScrollAlwaysVisible="true"
Run Code Online (Sandbox Code Playgroud)

所有这些都没有用.

user-interface android scroll nestedscrollview

5
推荐指数
0
解决办法
1161
查看次数

NestedScrollView 内的 RecyclerView 导致 RecyclerView 膨胀所有元素

我在将 RecyclerView 放置在 NestedScrollView 中时遇到问题,这会导致呈现 RecyclerView 适配器的所有元素。

这是一个相当大的问题,因为 RecyclerView 显示的列表可能包含数百个元素。

目前这会导致相当多的延迟(显然),因为它必须一次渲染所有视图,并且不能像 RecyclerView 通常那样重用任何已经膨胀的视图。

这是我当前的 XML(删除了一些膨胀以最小化它):

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    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:fillViewport="true"
    android:overScrollMode="never">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="90dp">

            <!-- Some content -->

        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <!-- Some more content -->

        </LinearLayout>

        <!-- Product list -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="12dp"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:overScrollMode="never"/>

        </LinearLayout>

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

这是我的 onCreateView() 来自 Fragment,它正在膨胀包含 NestedScrollView 和 RecyclerView 的视图:

@Override
public View onCreateView(LayoutInflater inflater, …
Run Code Online (Sandbox Code Playgroud)

xml android scrollview android-recyclerview nestedscrollview

5
推荐指数
1
解决办法
3295
查看次数

Recyclerview scrollToPosition 不适用于 NestedScrollView ?有吗?

所以我有Recyclerview一个NestedScrollView. 当我说recycleview.scrollToPosition(X)或者recycleview.getLayoutManager().scrollToPosition(X)它根本不起作用时。

如果我recycleviewnestedScrollView它移出它工作正常,但我不能这样做,因为布局结构!任何的想法?

scrollingView.requestChildFocus(recyclerView,recyclerView);
Run Code Online (Sandbox Code Playgroud)

尝试过这个,但没有专注于某个位置

android android-scrollview android-recyclerview nestedscrollview android-nestedscrollview

5
推荐指数
1
解决办法
2973
查看次数

如何在nestedscrollview中使用无限滚动recyclerview?

屏幕的高度不够,因为一个屏幕上有很多包含两个回收站视图的项目。所以我试图在嵌套滚动视图中有一个子视图。但是,所有物品都一次装载,否则回收商不会回收。

所以我阅读了其他文章并尝试过,但它对我不起作用。

例如添加app:layout_behavior="@string/appbar_scrolling_view_behavior"mRecyclerView.setNestedScrollingEnabled(false);

如果你知道怎么做,请告诉我。谢谢阅读。

这是我的java代码

myDataset = new ArrayList<>();
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.map_recycler_view);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(mcontext);
    mLayoutManager.setAutoMeasureEnabled(true);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new MyAdapter(this);
    mAdapter.setLinearLayoutManager(mLayoutManager);
    mAdapter.setRecyclerView(mRecyclerView);
    mRecyclerView.setAdapter(mAdapter);
Run Code Online (Sandbox Code Playgroud)

这是我的 xml 代码

<android.support.v4.widget.NestedScrollView
    android:id="@+id/nestedScrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


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


        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="180dp">

            <fragment
                android:id="@+id/googleMap"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </FrameLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:orientation="vertical">



            <android.support.v7.widget.RecyclerView
                android:id="@+id/tag_recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="blocksDescendants"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:layoutManager="LinearLayoutManager">

            </android.support.v7.widget.RecyclerView>

        </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">


                <android.support.v7.widget.RecyclerView
                    android:id="@+id/map_recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scrollbars="vertical"
                    android:nestedScrollingEnabled="false">
                </android.support.v7.widget.RecyclerView>

            </LinearLayout>

        </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

这是我的适配器代码,太多了,所以我上传了相关部分,它在到达回收视图底部时添加了一个新项目。

public …
Run Code Online (Sandbox Code Playgroud)

android infinite-scroll android-recyclerview nestedscrollview

5
推荐指数
1
解决办法
2536
查看次数