我已经包含RecyclerView在里面NestedScrollView并设置
mRecyclerView.setNestedScrollingEnabled(false);
由于滚动RecyclerView设置为false,因此我将无法获得 的滚动位置,RecyclerView因此我将无法将分页放入RecyclerView.
我也试过这个
mRecylerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if(dy > 0) {
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
if (!isLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
// End has been reached
// Do something
if (mOnLoadMoreListener != null) {
mOnLoadMoreListener.onLoadMore();
isLoading = true;
}
}
} …Run Code Online (Sandbox Code Playgroud) pagination android android-recyclerview nestedscrollview android-nestedscrollview
我有一个NestedScrollView孩子AppBarLayout,只有一个孩子 - LinearLayout。它们的顶部都没有填充,也没有边距,但NestedScrollView在NestedScrollView. 如何去除它?
我尝试过设置android:fillViewport="true",NestedScrollView但没有结果。
UPD:此空间与clipNoPadding 标志交互,但将所有填充设置为0 没有帮助。
<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
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:background="@color/colorAccent"
android:fillViewport="true"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
// and some more buttons, just to fill the space
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
android:background="@color/colorTransparent">
// I omit some code, as not-belonging to the question
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我确实扩展了 NestedScrollView 和 @Override 它的方法:onTouchEvent和onInterceptTouchEvent。问题是 super.onTouchEvent 从不调用 ACTION_DOWN (它由我的 onIntereceptTouchEvent 调用)并且因为 NestedScrollView 不移动,我得到错误:
onTouchEvent 中的无效pointerId=-1
当 ACTION_DOWN 被触发时,指针 id 在 NestedScrollView 的 onTouchEvent 方法中设置。
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
Run Code Online (Sandbox Code Playgroud)
我不能自己设置这个,重写整个 onTouchEvent 方法似乎是一个痛苦的计划。可以在这里使用帮助。当我单击不侦听触摸事件的 View 时,NestedScrollView 确实会移动(基本上就是这样我的 onInterecptTouchEvent 方法不被调用并且 ACTION_DOWN 在 NestedScrollView onTouchEvent 中处理)。
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.i(LOGTAG, String.valueOf(ev.getAction()));
final int action = MotionEventCompat.getActionMasked(ev);
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
mIsBeingDragged = false;
Log.i(LOGTAG, "is scrolling" + String.valueOf(mIsBeingDragged));
return false; // Do not …Run Code Online (Sandbox Code Playgroud) 有人知道我的布局有什么问题吗?我不知道为什么我的 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_200"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.rostata.alejo.vbmobileapp.ActivityResult"
tools:showIn="@layout/activity_home">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/one">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="0dp"
android:background="@color/White"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="20dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:id="@+id/relativeGridInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/White"
android:padding="10dp">
<RelativeLayout
android:id="@+id/headerThisNow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_bottom">
<Button
android:id="@+id/btnCloseWordOfTheDay"
style="?android:attr/buttonStyleSmall"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/ic_window_close"
android:text="" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:fontFamily="sans-serif-light-bold"
android:text="Word of the Day"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/grey_700"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" …Run Code Online (Sandbox Code Playgroud) android listview android-listview android-studio nestedscrollview
我有一个带有多个水平RecyclerView的ScrollView。问题是这样的:
当我垂直滚动以导航到我的应用程序时,当我触摸一个recyclerview进行水平滚动时,焦点仍然停留在滚动视图上,而我无法水平滚动。我必须松开手指并再次触摸才能垂直滚动。
我想赋予recyclerview适当的属性,这样我就可以水平滚动而不停止垂直滚动。
我尝试了多种解决方案:
谢谢你的帮助
android scrollview horizontal-scrolling android-recyclerview nestedscrollview
我有一个 ViewPager 项目,它看起来像这样:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingLeft="@dimen/material_horizontal_margin"
android:paddingRight="@dimen/material_horizontal_margin"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/group_footer_pager_item_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"/>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
TextView 的文本可能很长,但它的长度真的无关紧要,因为在任何情况下,如果它足够大可以滚动——文本的最后一行根本不可见。
这可能是什么原因?

我制作了一个页面NestedScrollView,其主体NestedScrollView是一个容器,用于保存以前请求的数据。但身体NestedScrollView已经溢出了。下面的代码:
NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
title: new Text(
nama,
style: TextStyle(color: putih),
),
iconTheme: IconThemeData(color: putih),
backgroundColor: colorPrimaryDark,
)
];
},
body: Container(
child: Column(
children: <Widget>[
Container(
color: goldtua,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text(
string.harga,
style: TextStyle(color: putih, fontSize: 24.0),
),
Text(
formatingRupiah(harga),
style: TextStyle(color: putih, fontSize: 24.0),
),
],
),
),
),
Expanded(
child: Padding(
padding: const …Run Code Online (Sandbox Code Playgroud) 我正在使用 NestedScrollView,并且收到错误 Error inflating class androidx.core.widget.NestedScrollView。我也尝试了 android.support.v4.widget.NestedScrollView。但两者都不起作用并且出现错误。在嵌套滚动视图中,有线性布局,在线性布局中,有 1 个 imageview、1 个 textview 和 recycler view。我是否必须添加任何依赖项才能用于 NestedScrollView?请帮助解决这个问题。先感谢您。
\n\n<?xml version="1.0" encoding="utf-8"?>\n<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:app="http://schemas.android.com/apk/res-auto"\n xmlns:tools="http://schemas.android.com/tools"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n tools:context=".AddFriend"\n android:padding="10dp">\n <androidx.core.widget.NestedScrollView\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:nestedScrollingEnabled="false">\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:orientation="vertical">\n\n <ImageView\n android:id="@+id/image"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:src="@mipmap/ic_group"/>\n <TextView\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:text="Group Members"\n android:textSize="30sp"\n android:gravity="center"\n />\n <androidx.recyclerview.widget.RecyclerView\n android:id="@+id/recycle_view"\n android:layout_width="match_parent"\n android:layout_height="wrap_content" />\n\n </LinearLayout>\n</androidx.core.widget.NestedScrollView>\n <ProgressBar\n android:id="@+id/progress"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_centerInParent="true"\n />\n</RelativeLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n2020-04-19 11:07:08.404 32661-32661/com.example.chatapp10 E/AndroidRuntime: FATAL EXCEPTION: main\n Process: com.example.chatapp10, PID: 32661\n java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.chatapp10/com.example.chatapp10.GroupMembersActivity}: android.view.InflateException: Binary …Run Code Online (Sandbox Code Playgroud) 我实现了类似的设计 https://github.com/chrisbanes/cheesesquare
一个可折叠的工具栏,其中的图像在向下滚动时会折叠
<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:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
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"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="@dimen/picture_heigth"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
</android.support.v4.view.ViewPager>
<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.v4.widget.NestedScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:foreground="?android:windowContentOverlay"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
LinearLayout
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Run Code Online (Sandbox Code Playgroud)
它很有用,但并不总是......例如,在线性布局中我有一个视图,在我的休息请求完成后被填充.这有效地推动了Viewpager的内容,当我再向下滚动时,一切都会再次进入正确的位置.
我在一些SO线程上看到,通过在NestedSCrollVew上设置"fill_vertical",它解决了一些问题.它实际上,内容不会落后但是scrollView的底部是CUT ...通过设置一些底部边距它解决了问题,但它是动态的我不知道提前什么边缘...
我正在尝试创建材质本机选项卡,因此当我们滚动页面时,应用程序栏会折叠,但选项卡栏应该始终可见,我在 flutter 中使用 NestedScrollView 实现了这一点
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
super.dispose();
_tabController.dispose();
}
@override
Widget build(BuildContext context) {
return NestedScrollView(
headerSliverBuilder: (BuildContext context, bool isBoxScrolled) {
return [
SliverAppBar(
title: Text("Scroller title"),
forceElevated: isBoxScrolled,
pinned: true,
floating: true,
bottom: TabBar(
tabs: [Tab(text: "tab1"), Tab(text: "tab2")],
controller: _tabController))
];
}, …Run Code Online (Sandbox Code Playgroud) 我在Flutter文档的例子中写了一个NestedScrollView界面,但是当我看ListView作为body时,我发现ListView和SliverAppBar之间有一个奇怪的间隙。我该怎么做才能删除这个差距
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (context, boxIsScrolled) {
return [
SliverAppBar(
pinned: true,
expandedHeight: 100,
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background: Container(
color: Colors.red,
),
),
),
];
},
body: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return Container(
child: Text(
"$index",
),
color: Colors.green,
);
},
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
试过:
NestedScrollView ns =(NestedScrollView) findViewById(R.id.nested_scroll);
ns.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
}
});
Run Code Online (Sandbox Code Playgroud)
但是卡住了,有没有人有想法?
只是为了清除我想要的东西 - 我希望能够观察滚动状态(如在RecyclerView的addOnScrollListener中)并且只在滚动结束(空闲)时检查一次,如果用户滚动到NestedScrollView的末尾.
android scrollview android-scrollview nestedscrollview android-nestedscrollview
我用ViewPager与NestedScrollView和RecyclerView。加载屏幕时,所有工作都很好,但首先要加载回收者视图,然后再用急速(不顺畅)的方式查看寻呼机,并且看起来不太好。
现在,我正在设计方面实现,而没有为视图分页器设置任何适配器。我没有为视图分页器或recyclerview填充数据。
Xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:orientation="vertical">
<hammerapps.views.CustomNestedScrollView
android:id="@+id/scroll_main"
android:layout_width="match_parent"
android:layout_gravity="fill_vertical"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager_banner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_bg"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="24dp"
android:orientation="horizontal"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<hammerapps.views.TextViewKarlaRegular
android:id="@+id/txt_cat_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="4dp"
android:text="EXPLORE"
android:textColor="@color/blue_color"
android:textSize="14dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_home_explore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="vertical"
android:visibility="visible">
<hammerapps.views.TextViewKarlaBold
android:id="@+id/txt_cat1"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) nestedscrollview ×13
android ×10
scrollview ×4
flutter ×3
listview ×2
xml ×2
androidx ×1
behind ×1
dynamic ×1
height ×1
java ×1
pagination ×1
sliverappbar ×1
tabs ×1
textview ×1
touch-event ×1