마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

슬라이드 메뉴 안에 있는 리싸이클러뷰에서 스크롤이 안되요 ㅠㅠ

0 추천

DrawerLayout 을 쓰고잇고

그안의 내용물중에 (Horizontal) RecyclerView 가 있습니다.

문제는 저 리싸이클러뷰의 좌우 스크롤이 먹히질 않네요.

대신 드로어가 열렸다 닫혔다 해버립니다.

 

스크롤 이벤트를 드로어가 잡아먹는것 같은데..저같이 취미생활로 하는 초짜에겐 너무 어렵네용 ㅠㅠ

 

항상 좋은 답변 감사드립니다~~추운데 감기조심하세요

 

김원장91 (1,470 포인트) 님이 2016년 12월 11일 질문

1개의 답변

0 추천
 
채택된 답변
https://kairo96.gitbooks.io/android/content/ch3.21.html
http://stackoverflow.com/questions/18400910/seekbar-in-a-navigationdrawer
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" >
        <HorizontalScrollView
            android:id="@+id/hv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#000000"
            android:alpha="0.5">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="200dip"
                    android:layout_height="match_parent"
                    android:background="#ff0000"
                    android:gravity="center"
                    android:text="#ff0000" />

                <TextView
                    android:layout_width="200dip"
                    android:layout_height="match_parent"
                    android:background="#00ff00"
                    android:gravity="center"
                    android:text="#00ff00" />

                <TextView
                    android:layout_width="200dip"
                    android:layout_height="match_parent"
                    android:background="#0000ff"
                    android:gravity="center"
                    android:text="#0000ff" />
            </LinearLayout>
        </HorizontalScrollView>
    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>
HorizontalScrollView hv = (HorizontalScrollView) findViewById(R.id.hv);
hv.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {

        int action = motionEvent.getAction();
        switch (action)
        {
            case MotionEvent.ACTION_DOWN:
                // Disallow Drawer to intercept touch events.
                view.getParent().requestDisallowInterceptTouchEvent(true);
                break;

            case MotionEvent.ACTION_UP:
                // Allow Drawer to intercept touch events.
                view.getParent().requestDisallowInterceptTouchEvent(false);
                break;
        }

        // Handle seekbar touch events.
        view.onTouchEvent(motionEvent);
        return true;
    }
});
익명사용자 님이 2016년 12월 12일 답변
김원장91님이 2020년 6월 21일 채택됨
...