NavigationView headerLayout中巢狀RecyclerView滑動衝突問題
阿新 • • 發佈:2018-11-03
<?xml version="1.0" encoding="utf-8"?> <com.vechain.vecar.ui.view.MyDrawerLayout 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:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:openDrawer="start"> <include layout="@layout/content_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <com.vechain.vecar.ui.view.MyNavigationView android:id="@+id/nav_view" android:layout_width="@dimen/nav_view_width" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/black" app:headerLayout="@layout/nav_header_main" /> </com.vechain.vecar.ui.view.MyDrawerLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black" android:gravity="center_horizontal" android:orientation="vertical" android:paddingEnd="@dimen/nav_h_padding" android:paddingStart="@dimen/nav_h_padding" android:theme="@style/ThemeOverlay.AppCompat.Dark"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin_40" android:gravity="center_vertical" android:paddingStart="@dimen/nav_h_bar_padding_start"> <ImageView android:id="@+id/userIcon" android:layout_width="@dimen/nav_h_icon_length" android:layout_height="@dimen/nav_h_icon_length" android:src="@drawable/fans" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="@dimen/nav_h_nickname_margin_start" android:text="@string/fans_name" android:textSize="@dimen/common_font" /> <ImageView android:id="@+id/user_center" android:layout_width="@dimen/nav_h_icon_length" android:layout_height="@dimen/nav_h_icon_length" android:layout_alignParentEnd="true" android:src="@drawable/user" /> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/nav_h_margin_bottom" android:layout_marginEnd="@dimen/nav_h_margin_end" android:layout_marginStart="@dimen/nav_h_margin_start" android:gravity="center_horizontal" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/nav_h_user_center_spacing" android:gravity="center_horizontal" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/usable" android:textColor="@color/white" android:textSize="@dimen/common_font" /> <TextView android:id="@+id/usable" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/nav_h_12" android:textColor="@color/white" android:textSize="@dimen/nav_h_big_font" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginBottom="@dimen/middle_font" android:layout_marginTop="@dimen/middle_font" android:background="@color/white" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:orientation="vertical" android:textColor="@color/white"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/total_income" android:textColor="@color/white" android:textSize="@dimen/middle_font" /> <TextView android:id="@+id/total_income" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/nav_h_user_center_spacing" android:textColor="@color/white" android:textSize="@dimen/middle_font" /> </LinearLayout> <View android:layout_width="1dp" android:layout_height="match_parent" android:layout_marginBottom="@dimen/item_content_padding" android:layout_marginTop="@dimen/item_content_padding" android:background="@color/white" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/total_expend" android:textColor="@color/white" android:textSize="@dimen/middle_font" /> <TextView android:id="@+id/total_expend" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/nav_h_user_center_spacing" android:textColor="@color/white" android:textSize="@dimen/middle_font" /> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/consumption_info_layout" android:layout_width="match_parent" android:layout_height="@dimen/nav_h_list_height" android:layout_marginEnd="@dimen/nav_h_margin_end" android:layout_marginStart="@dimen/nav_h_margin_start" android:orientation="vertical" android:visibility="invisible"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/nav_h_list_margin_bottom" android:text="@string/consumption_records" android:textColor="@color/white" android:textSize="@dimen/middle_font" /> <com.vechain.vecar.ui.view.MyRecyclerView android:id="@+id/consumption_info" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical"> <com.vechain.vecar.ui.view.UnderLineButton android:id="@+id/quit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:text="@string/exit" android:textSize="@dimen/common_font" /> </RelativeLayout> </LinearLayout>
讓
RecyclerView不在向父類傳遞觸控事件即可解決:
getParent().requestDisallowInterceptTouchEvent(true);