在滚动中在另一个片段视频视图中叠加一个片段的视频缩略图

时间:2016-08-05 10:37:31

标签: android listview android-fragments android-videoview

在片段1中显示一个视频,它包含一个按钮。当我们点击按钮时,它导航到下一个片段视频视图,进入onPause状态。第二个片段包含视频观察列表,当我们播放并完成滚动时,第一个片段videoview拇指图像正在替换第二个片段,同时进行滚动。我不做允许进入下一个片段吗?

我的代码是

当我在第一个片段中完成下一个按钮时,我写了一个像这样的代码

            if (videoview.isPlaying()) {
                try {

                    videoview.pause();
                    youtube_view.onPause();
                    youtube_view.stopLoading();
                    imgv_videoimage.setVisibility(View.VISIBLE);
                    image_view_thumb.setVisibility(View.GONE);
                    rel_video.setVisibility(View.GONE);
                    youtube_view.setVisibility(View.GONE);
                    videoview.setVisibility(View.GONE);
                    img_play_icon_image.setVisibility(View.VISIBLE);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        profilepic_clicked = "ProfileClicked";
        Profile fragment = new Profile();
        bundle.putString("Tweak_Userid", str_persionuserid);
        fragment.setArguments(bundle);
        FragmentManager fragmentManager = (getActivity()).getFragmentManager();
        FragmentTransaction ft = fragmentManager
                .beginTransaction();
        ft.add(R.id.home_container, fragment);
        ft.addToBackStack(VideoDetailFragment.class
                .getName());
        ft.commit();
        SharedPreferences.Editor editor=prefs.edit();
        editor.putString("TweakUserid", str_persionuserid);
        editor.commit();
        category = false;
        try {
            youtube_view.onPause();
            youtube_view.stopLoading();
            progressbar.setVisibility(View.GONE);
            rel_video.setVisibility(View.GONE);
            imgv_videoimage.setVisibility(View.VISIBLE);
            img_play_icon_image.setVisibility(View.VISIBLE);
            img_play_icon.setVisibility(View.GONE);
            youtube_icon.setVisibility(View.GONE);
            ll_andout_video.setVisibility(View.INVISIBLE);
            ll_youtube.setVisibility(View.GONE);
        } catch (Exception e) {
            e.printStackTrace();
        }

这是我的第二个片段布局文件

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/white"
          android:clickable="true"
      >
       <RelativeLayout
            android:layout_width="match_parent"
              android:layout_height="match_parent">
               <RelativeLayout
                   android:id="@+id/navbar"
                  android:layout_width="fill_parent"
                  android:layout_height="76dp"

                  android:visibility="visible"
                  >
        <LinearLayout
            android:id="@+id/ll_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:background="@drawable/statusbar"></LinearLayout>
        <View
            android:id="@+id/line"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:background="#ffff01"
            android:layout_below="@+id/ll_view"/>

        <LinearLayout
            android:id="@+id/ll_back_button"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:visibility="gone"
            android:layout_marginTop="25dp"></LinearLayout>
        <ImageView
            android:id="@+id/imgv_back"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:background="@drawable/back"
            android:layout_marginLeft="5dp"
            android:visibility="gone"
            android:layout_marginTop="15dp"
            android:layout_below="@+id/line"
            />

        <TextView
            android:id="@+id/txtv_myuserloginname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"

            android:layout_marginTop="10dp"
            android:layout_centerHorizontal="true"
            android:textColor="#222222"

            android:gravity="center"
            android:textSize="@dimen/title_size"
            android:layout_below="@+id/line"
            />
    </RelativeLayout>
    <View
        android:id="@+id/view"
        android:layout_below="@+id/navbar"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="#ffff01"/>

                      

    <ListView
        android:id="@+id/ll_Profilelist_liked"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:groupIndicator="@android:color/transparent"
        android:visibility="visible"
        android:scrollbars="none"
        android:layout_below="@+id/view"
        android:divider="@null"


        />
    </android.support.v4.widget.SwipeRefreshLayout>

    <ProgressBar
        android:theme="@style/CircularProgress"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_centerInParent="true"
        android:id="@+id/progressbar"
        android:visibility="gone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

在进入第二个片段之前的第一个片段中。我刚刚进入视频观看并停止播放视频。

                videoview.stopPlayBack();
                youtube_view.stopPlayBack();
                youtube_view.setVisibility(view.GONE);
                videoview.setVisibility(view.GONE);