我有RecyclerView一个LinearLayoutManager和Adapter:
@Override public int getItemViewType(int position) {
return position == 0? R.layout.header : R.layout.item;
}
Run Code Online (Sandbox Code Playgroud)
这是header.xml:
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
/>
Run Code Online (Sandbox Code Playgroud)
我想要实现的是在我可以点击的地方找到一个洞.我尝试了很多组合以下属性无济于事:RecyclerViewRecyclerView
android:background="@android:color/transparent"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:longClickable="false"
Run Code Online (Sandbox Code Playgroud)
如何让列表中的第一个项目透明(允许触摸事件到它后面的任何东西),但让它仍然占据空间?
android android-layout android-listview recycler-adapter android-recyclerview
我有一个布局,其中RecyclerView位于具有几个按钮的另一个布局之上.第一个回收商项目是一个带有较大上边距的标题,以在其上方创建一个空白区域.现在我希望点击通过该开放空间工作,刷卡也应该滚动回收器.视图位于一个简单的框架中.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<package.FeedBackgroundView
android:id="@+id/feed_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
回收者仅使用顶部填充或边距消耗所有点击.我需要点击才能通过,但是滑动应该留在回收器中进行滚动.
编辑:
我的点击工作,解决方案是:
recycler.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
background.dispatchTouchEvent(event);
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
现在我有一个问题,因为我翻译了背景(视差),点击没有到达正确的位置.我是否也要翻译这些活动?