Recyclerview项目触摸问题

时间:2016-06-08 10:56:47

标签: android android-recyclerview

我在RecyclerView中有多个视频。我已经制作了布局,以在主要活动布局中显示视频的描述。我希望当我点击播放视频必须显示描述的项目时,但当我点击视频未播放的下一个项目时,它也会显示其描述。我不想表明这种描述。

 view.setOnTouchListener(new View.OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        if (event.getAction() == MotionEvent.ACTION_DOWN) {
                            if (mediacontroller_progress.getProgress() != 0) {
                                if (title_layout.getVisibility() == View.VISIBLE) {
                                    title_layout.setVisibility(View.GONE);
                                    desc_layout.setVisibility(View.GONE);
                                    mediaControls.setVisibility(View.GONE);
                                } else {
                                    title_layout.setVisibility(View.VISIBLE);
                                    desc_layout.setVisibility(View.VISIBLE);
                                    mediaControls.setVisibility(View.VISIBLE);
                                }
                            }
                        }
                        return true;
                    }
                });



<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listCoordinate"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/videoFrame">

        <utils.VideoRecyclerview
            android:id="@+id/videoRecyclerview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true"
            android:footerDividersEnabled="false"
            android:gravity="center_vertical" />


        <LinearLayout
            android:id="@+id/collapseView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="2">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/colorPrimary"
                android:orientation="vertical">

                <LinearLayout
                    android:id="@+id/title_layout"
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:orientation="horizontal">

                    <ImageView
                        android:id="@+id/imageView"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:src="@drawable/logo" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <TextView
                            android:id="@+id/videoTitle"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:paddingBottom="2dp"
                            android:paddingLeft="5dp"
                            android:paddingRight="5dp"
                            android:text="Category"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textColor="#ffffff"
                            android:textSize="15sp" />

                        <TextView
                            android:id="@+id/addedon"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:paddingBottom="2dp"
                            android:paddingLeft="5dp"
                            android:paddingRight="5dp"
                            android:text="Category"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textColor="#ffffff"
                            android:textSize="15sp" />
                    </LinearLayout>

                    <ImageView
                        android:id="@+id/shareButton"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_gravity="center"
                        android:padding="8dp"
                        android:src="@drawable/share" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/desc_layout"
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:layout_gravity="bottom"
                    android:background="@color/colorPrimary"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/desc"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:ellipsize="end"
                        android:lines="3"
                        android:maxLines="100"
                        android:padding="10dp"
                        android:scrollbars="vertical"
                        android:text="Description"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textColor="@color/textcolor"
                        android:textSize="15sp" />


                </LinearLayout>

                <LinearLayout
                    android:id="@+id/mediaControls"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_alignParentBottom="true"
                    android:layout_gravity="bottom"
                    android:background="@color/colorPrimary"
                    android:orientation="horizontal">

                    <RelativeLayout
                        android:layout_width="50dp"
                        android:layout_height="match_parent"
                        android:padding="5dp">

                        <ImageView
                            android:id="@+id/play"
                            android:layout_width="75dp"
                            android:layout_height="match_parent"
                            android:src="@drawable/ic_play_arrow_black_24dp" />

                        <ImageView
                            android:id="@+id/pause"
                            android:layout_width="73dp"
                            android:layout_height="match_parent"
                            android:src="@drawable/ic_pause_black_24dp" />
                    </RelativeLayout>

                    <SeekBar
                        android:id="@+id/mediacontroller_progress"
                        style="?android:attr/progressBarStyleHorizontal"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:max="100"
                        android:maxHeight="1000dp"
                        android:minHeight="2dip"
                        android:progress="0"
                        android:progressDrawable="@drawable/progress_drawable"
                        android:thumb="@drawable/thumb"
                        android:thumbOffset="0px" />


                    <TextView
                        android:id="@+id/lblCurrentPosition"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:padding="10dp"
                        android:text="@string/empty_message"
                        android:textColor="#FFF"
                        android:textSize="15sp" />

                    <RelativeLayout
                        android:layout_width="50dp"
                        android:layout_height="match_parent"
                        android:padding="5dp">

                        <ImageView
                            android:id="@+id/fullscreen"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:clickable="true"
                            android:src="@drawable/fullscreen" />

                        <ImageView
                            android:id="@+id/fullscreenExit"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:clickable="true"
                            android:src="@drawable/fullscreen_exit" />
                    </RelativeLayout>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
    </FrameLayout>
</android.support.design.widget.CoordinatorLayout>
<!-- android:layout_gravity="start"-->
<LinearLayout
    android:id="@+id/mDrawerLinear"
    android:layout_width="280dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/colorPrimary"
    android:gravity="center"
    android:orientation="horizontal">

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:layout_weight="1"
        android:dividerHeight="0dp" />
</LinearLayout>

0 个答案:

没有答案