标签: nestedscrollview

如果ListView在NestedScrollView中,match_parent不适用于ListView

在我的应用程序中,我正在使用它ListView,它在一个内部NestedScrollView.当我设置heightListView,以match_parent不覆盖整个屏幕.我想要ListView覆盖整个屏幕.

我的XML文件:

<?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:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

        <ListView
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:divider="@null" />
        </LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

xml android listview nestedscrollview

10
推荐指数
2
解决办法
6032
查看次数

webview height在nestedScrollView中无限增长

这是我的布局.当我加载google.com时,webview的高度会无限增长.webview的onSizeChange函数不断被调用,我可以看到webview不断无限扩展.我已经尝试了22.2.1和23.1.0的设计和appcompat库并没有效果.

有解决方案吗 : - |

<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:background="@android:color/black">

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="fill_vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <com.example.ajay.scrollabletoolbar.MyWebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"/>
</android.support.v4.widget.NestedScrollView>

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbarlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true">

    <android.support.v7.widget.Toolbar
        android:id="@+id/restricted_browser_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:background="@color/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FFFFFF"
            android:descendantFocusability="beforeDescendants"
            android:focusableInTouchMode="true">

            <EditText
                android:id="@+id/current_url"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerVertical="true"
                android:backgroundTint="@android:color/darker_gray"
                android:dropDownAnchor="@+id/restricted_browser_toolbar"
                android:hint="hint hint"
                android:imeOptions="actionGo|flagNoExtractUi"
                android:inputType="textNoSuggestions|textUri"
                android:paddingBottom="8dp"
                android:paddingEnd="8dp"
                android:paddingStart="8dp"
                android:singleLine="true"/>

            <ImageView
                android:id="@+id/clear_url_text"
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_alignRight="@+id/current_url"
                android:layout_centerVertical="true"
                android:layout_marginRight="8dp"
                android:src="@android:drawable/ic_menu_close_clear_cancel"
                android:visibility="gone"/>
        </RelativeLayout>
    </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)

android webview android-coordinatorlayout android-collapsingtoolbarlayout nestedscrollview

10
推荐指数
1
解决办法
3884
查看次数

Recycler view + View Pager + Nested ScrollView + CoordinatorLayout

在此输入图像描述我正在进行布局,使得包含包含回收器视图的片段的ViewPager放置在协调器布局的nester scrollView中.

问题是,一旦我点击了回收站视图,嵌套的滚动视图就不起作用了.

是否有任何可能的方法来使这些布局也滚动

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:id="@+id/lin"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ViewPager
                android:id="@+id/view_pager"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />


        </LinearLayout>


    <NestedScrollView>

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        app: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"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="190dp"
                android:minHeight="190dp"
                app:layout_collapseMode="parallax" >

                <ViewFlipper
                    android:id="@+id/view_flipper"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <!--<ImageView
                        android:id="@+id/backdrop"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:adjustViewBounds="true"
                        android:fitsSystemWindows="true"
                        android:scaleType="centerCrop"/>-->

                </ViewFlipper>

            </FrameLayout>

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

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

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:background="?attr/colorPrimary" />

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

android android-viewpager android-recyclerview android-coordinatorlayout nestedscrollview

9
推荐指数
1
解决办法
7064
查看次数

滚动时在NestedScrollView中隐藏FAB

我有一个nestedscrollview,内容像一些linearlayouts和textviews.我也出于某些原因使用了floatingactionbutton库.所以我不能使用任何行为.我不知道如何处理scrollviewlistener从scrollview隐藏并像动作一样动态显示fab.

有什么建议如何在滚动时隐藏和显示晶圆厂?

android scrollview floating-action-button nestedscrollview

9
推荐指数
2
解决办法
1万
查看次数

scrollview内的Recyclerview-如何滚动整个内容?

我在Scrollview中有Recyclerview

 <Scrollview
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

    <LinearLayout
        android:id="@+id/layoutStaticContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

       //Static content.
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="100dp">
           .
           .
        <LinearLayout>

         //Dynamic content(newsfeed)
         <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
 </ScrollView>
Run Code Online (Sandbox Code Playgroud)

现在,在滚动时,layoutStaticContent在顶部保持修复,并在底部独立滚动回收内容.如何滚动整个内容即(layoutStaticContent + recyclerview内容),这样只有1个scrollview?我也尝试用Nestedscrollview替换scrollview但没有成功.

android android-recyclerview nestedscrollview

9
推荐指数
2
解决办法
6439
查看次数

为什么Android CollapsingToolbarLayout + NestedScrollView在显示软键盘时不滚动到End

使用appcompat 23.1.1,当显示软键盘时,无法滚动到NestedScrollView内的EditText的末尾.如果键盘被隐藏,它将滚动到最终结果.

换句话说,软键盘隐藏了文本的最后部分.

已经问过这个问题的变化,没有明确的答案.大多数人都认为appcompat 22.x是错误的.这已修复为23.1?如果没有,现在是否有更好的解决方法.

要重现此问题,只需创建使用Android Studio,创建一个新项目并选择"滚动应用程序",然后将TextView更改为EditText.

我尝试添加到清单,

 android:windowSoftInputMode="adjustResize"
Run Code Online (Sandbox Code Playgroud)

但它没有任何区别.

作为参考,这里是项目文件:

https://gist.github.com/anonymous/73acc2d39f4e90c51217

感谢您的任何帮助和建议

编辑#1

appcompat-v7:23.2.0仍然如此

编辑#2

仍然存在appcompat 23.3.0可能是一个错误.请参阅此处, https://code.google.com/p/android/issues/detail?id = 182362

android android-collapsingtoolbarlayout nestedscrollview

9
推荐指数
1
解决办法
1668
查看次数

NestedScrollView onBindViewHolder中的RecyclerView调用所有getItemCount大小

当我放入RecyclerView内部NestedScrollView然后onBindViewHolder调用所有行,比如说我有大小为30的列表然后一次onBindViewHolder调用所有30行,即使没有滚动

 RecyclerView list;
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        list.setLayoutManager(layoutManager);
        layoutManager.setAutoMeasureEnabled(true);
        list.setNestedScrollingEnabled(false);
        list.addItemDecoration(new VerticalSpaceItemDecoration(5));
        list.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

我的xml是

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbars="none"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/grey">
    <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_views"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/info"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:textAlignment="center"

            android:visibility="visible"
           />
Run Code Online (Sandbox Code Playgroud)

但如果我删除NestedScrollView它正常工作.

android android-recyclerview nestedscrollview android-nestedscrollview

9
推荐指数
1
解决办法
1394
查看次数

RecyclerView一次调用onCreateViewHolder和onBindViewHolder获取所有项目

我有一个recyclerView能够在屏幕上显示最多3个项目,但它会同时调用onCreateViewHolder和onBindViewHolder列表中的所有45个项目(如下面的日志中所示).

不应该只在我将这些项目滚动到屏幕时调用这些方法吗?

*我使用0和1的列表作为测试来定义它应该使用的布局.

我的适配器代码

public class MyRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

int[] post_list;
private static final int TYPE_0 =0;
private static final int TYPE_1=1;
private LayoutInflater inflater;
private Context context;
Activity mActivity;

public MyRecyclerAdapter(Context context, int[] list, Activity mActivity){
    this.context=context;
    inflater=LayoutInflater.from(context);
    this.list=list;
    this.mActivity = mActivity;
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Log.e("onCreateViewHolder", "CALLED");
    if(viewType== TYPE_0){
        View view=inflater.inflate(R.layout.layout_type0, parent,false);
        Type0Holder holder=new Type0Holder(view);
        return holder;
    }
    else{
        View view=inflater.inflate(R.layout.layout_type1, parent,false);
        Type1Holder holder=new Type1Holder (view);
        return holder;
    }


}

@Override
public …
Run Code Online (Sandbox Code Playgroud)

performance android android-recyclerview nestedscrollview

8
推荐指数
1
解决办法
1362
查看次数

滚动到折叠视图而不使用工具栏

我正在制作类似于最近android的状态栏的布局.

在此输入图像描述

我有两个Views内部容器.ViewPagerRecyclerView.默认行为应该是当我滚动时RecyclerView,我想ViewPager减小尺寸,反之亦然.

在此输入图像描述

逻辑:

viewPagerMaxHeight = 200;
if scrollTop
  is ViewPager.height > viewPagerMaxHeight?
    YES: Prevent Scroll and Decrease ViewPager size apropriatry
    No: Scroll RecyclerView
if scrollBottom
  did we scroll to position 0?
    YES: Start increasing ViewPager size
    No: Scroll RecyclerView
Run Code Online (Sandbox Code Playgroud)

几个注意事项: - RecyclerView包含各种尺寸的物品. - 有时会删除和添加项目 - 这是一个简单的RecyclerView,而不是在通知中它们相互折叠.

我可以自己构建大部分逻辑但是我无法做出适当的监听器RecyclerView,它将返回滚动的方向和数量.防止RecyclerView滚动是一个奖励

编辑:

我在github上做了一个例子

v.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview nestedscrollview android-nestedscrollview

8
推荐指数
1
解决办法
2068
查看次数

如何使用tabBar实现sliverAppBar

扑文档显示演示SliverAppBar+ TabBar+ TabBarView with ListView的使用NestedScrollView,这是一个有点复杂,所以我不知道是否有一个简单而明确的方式来实现它。我尝试了这个:

CustomScrollView
  slivers:
    SliverAPPBar
      bottom: TabBar
    TabBarView
      children: MyWidget(list or plain widget)
Run Code Online (Sandbox Code Playgroud)

出现错误:

扑:下列说法被扔建筑滚动(axisDirection:对,物理:
扑:一个RenderViewport预计类型RenderSliv​​er的孩子,但收到类型_RenderExcludableScrollSemantics的孩子。
扑:RenderObjects期望特定类型的孩子,因为他们与布局过程中他们的孩子协调例如,RenderSliv​​er不能是RenderBox的子级,因为RenderSliv​​er不了解RenderBox布局协议。

flutter:引发了另一个异常:'package:flutter / src / widgets / framework.dart':失败的断言:3497行pos 14:'owner._debugCurrentBuildTarget == this':不正确。

这是我的代码:

import 'package:flutter/material.dart';

main(List<String> args) {
  runApp(MyScrollTabListApp());
}

class MyScrollTabListApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: "aa", home: MyScrollTabListHomePage());
  }
}

class MyScrollTabListHomePage extends StatefulWidget {
  @override
  MyScrollTabListHomePageState createState() {
    return new MyScrollTabListHomePageState();
  }
}

class MyScrollTabListHomePageState …
Run Code Online (Sandbox Code Playgroud)

nestedscrollview flutter flutter-sliver

8
推荐指数
2
解决办法
6515
查看次数