我在 NestedScrollView 中有一些水平可滚动的回收器视图。如何仅禁用回收器视图中的垂直滚动并将此垂直触摸传递给父 NestedScrollView?
问问题
421 次
2 回答
0
我会说你设置了一个触摸监听器RecyclerView
并检测它是水平滚动还是垂直滚动。true
水平时返回,false
垂直时返回。
RecyclerView rv = findViewById(R.id.recyclerView);
rv.setOnTouchListener(new View.OnTouchListener {
public boolean onTouch(View v, MotionEvent event) {
// your logic here
}
});
参考 - View.OnTouchListener
于 2016-04-22T07:47:21.107 回答
0
尝试这个
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
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="@color/toolbarScrim"
app:title=" "
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ArticleImg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/article_img"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffe5e5e5"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.global.jet.global.BizForum.ArticleView"
tools:showIn="@layout/activity_article_view">
<RelativeLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view2">
<ImageView
android:layout_margin="10dp"
android:layout_width="64dp"
android:layout_height="64dp"
android:id="@+id/imageView9"
android:background="@drawable/rv"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
/>
<TextView
android:layout_marginLeft="10dp"
android:textColor="@color/link"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/ArticlePostName"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView9"
android:layout_toEndOf="@+id/imageView9" />
<ImageView
android:layout_marginRight="10dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/ic_add_black_18dp"
android:id="@+id/button3"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_marginLeft="10dp"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="31 oct 2015,12:49-"
android:id="@+id/ArticleDate"
android:layout_below="@+id/ArticlePostName"
android:layout_toRightOf="@+id/imageView9"
android:layout_toEndOf="@+id/imageView9" />
<TextView
android:layout_marginLeft="10dp"
android:textColor="@color/link"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/ArticleDes"
android:layout_below="@+id/ArticleDate"
android:layout_toRightOf="@+id/imageView9"
android:layout_toEndOf="@+id/imageView9" />
<ImageView
android:background="@drawable/clock_ic"
android:textSize="14sp"
android:layout_width="18dp"
android:layout_height="18dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="@+id/textView15"
android:layout_alignTop="@+id/ArticleDate"
android:layout_toRightOf="@+id/ArticleDate"
android:layout_toEndOf="@+id/ArticleDate" />
<TextView
android:layout_marginLeft="5dp"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="3 min read"
android:id="@+id/ArticleTime"
android:layout_alignTop="@+id/textView15"
android:layout_toRightOf="@+id/textView15"
android:layout_toEndOf="@+id/textView15" />
<View
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/grey_333"
android:id="@+id/textView17"
android:layout_below="@+id/imageView9"
android:layout_alignLeft="@+id/imageView9"
android:layout_alignStart="@+id/imageView9"
android:layout_alignRight="@+id/button3"
android:layout_alignEnd="@+id/button3" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.RecyclerView
android:id="@+id/scrollableview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
于 2016-04-22T07:38:48.510 回答