我在标签式布局中有一个cardView / recylerView。尝试在标签之间滑动时没有任何反应,但如果我删除了textView,我现在可以再次滑动。
如何将触摸事件发送到卡以绕过textView。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bills_layout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center_horizontal">
<android.support.v7.widget.CardView
android:id="@+id/bills_card"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="fill_parent"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="5dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:id="@+id/bills_layout_select"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="3.5"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:clickable="false"
android:focusable="false"
android:measureWithLargestChild="true">
<TextView
android:id="@+id/billsName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:includeFontPadding="false"
android:singleLine="true"
android:text="Click"
android:layout_weight="1"
android:textSize="40sp"
android:gravity="center"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
<TextView
android:id="@+id/billsAmount"
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="To Add"
android:layout_weight="1"
android:includeFontPadding="false"
android:singleLine="true"
android:textSize="40sp"
android:gravity="center"
android:textColor="@color/material_deep_teal_200"
android:focusable="false"
android:clickable="false"
android:focusableInTouchMode="false" />
<TextView
android:id="@+id/nextBillsDate"
android:layout_width="match_parent"
android:layout_height="0dp"
android:includeFontPadding="false"
android:text="Bills"
android:layout_weight="1"
android:singleLine="true"
android:textSize="40sp"
android:gravity="center"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
</LinearLayout>
<View
android:id="@+id/bill_selected_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorSelection"
android:visibility="invisible" />
<View
android:id="@+id/bill_due_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorClear"
android:visibility="invisible" />
</android.support.v7.widget.CardView>
</RelativeLayout>
答案 0 :(得分:0)
删除了textViews并替换为grantland.widget.AutofitTextView,一切正常。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bills_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<android.support.v7.widget.CardView
android:id="@+id/bills_card"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="5dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:id="@+id/bills_layout_select"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:paddingLeft="5dp">
<me.grantland.widget.AutofitTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/billsName"
android:layout_gravity="center_horizontal"
android:textSize="50dp"
android:textColor="@color/material_deep_teal_200"
android:singleLine="true" />
<me.grantland.widget.AutofitTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/billsAmount"
android:layout_gravity="center_horizontal"
android:textSize="50dp"
android:singleLine="true" />
<me.grantland.widget.AutofitTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nextBillsDate"
android:layout_gravity="center_horizontal"
android:textSize="50dp"
android:singleLine="true" />
</LinearLayout>
<View
android:id="@+id/bill_selected_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorSelection"
android:visibility="invisible" />
<View
android:id="@+id/bill_due_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorClear"
android:visibility="invisible" />
</android.support.v7.widget.CardView>
</RelativeLayout>