View Code
利用FrameLayout的层叠效果,实现视频控件面板在视频层之上显示,利用视频控件的单击事件,实现视频点击之后改变视频控制面板的隐藏和显示。其他的视频播放控制代码基本以下相似


布局文件改变:


1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:paddingBottom="0dp" 7 android:paddingLeft="0dp" 8 android:paddingRight="0dp" 9 android:orientation="vertical" 10 android:paddingTop="0dp" 11 tools:context="com.example.videodong.MainActivity"> 12 13 <TextView 14 android:layout_width="wrap_content" 15 android:layout_height="wrap_content" 16 android:text="视频播放器:\n" 17 android:textSize="15dp" 18 android:id="@+id/textView" /> 19 <FrameLayout 20 android:layout_width="match_parent" 21 android:background="@color/colorBlack" 22 android:layout_height="230dp"> 23 <VideoView 24 android:layout_width="match_parent" 25 android:layout_gravity="center" 26 android:layout_height="230dp" 27 android:id="@+id/videoView" 28 /> 29 <FrameLayout 30 android:layout_width="match_parent" 31 android:layout_gravity="bottom" 32 android:id="@+id/vv_framel" 33 android:layout_height="wrap_content"> 34 <ImageView 35 android:layout_width="match_parent" 36 android:background="@color/colorWhite" 37 android:alpha="0.5" 38 android:layout_height="match_parent" /> 39 <LinearLayout 40 android:layout_width="match_parent" 41 android:orientation="vertical" 42 43 android:layout_height="wrap_content"> 44 <ProgressBar 45 android:id="@+id/vv_bar" 46 style="?android:attr/progressBarStyleHorizontal" 47 android:layout_width="match_parent" 48 android:layout_height="wrap_content"/> 49 <LinearLayout 50 android:layout_width="match_parent" 51 android:orientation="horizontal" 52 android:layout_gravity="center" 53 android:layout_height="wrap_content"> 54 <TextView 55 android:layout_width="wrap_content" 56 android:text="时间轴为:0.00/000" 57 android:id="@+id/vv_starttime" 58 android:layout_weight="1" 59 android:layout_height="wrap_content" /> 60 <Button 61 android:layout_width="wrap_content" 62 android:text="开始" 63 style="?android:attr/buttonStyleSmall" 64 android:id="@+id/vv_start" 65 android:layout_height="wrap_content" /> 66 <Button 67 android:layout_width="wrap_content" 68 android:text="暂停" 69 android:id="@+id/vv_pause" 70 style="?android:attr/buttonStyleSmall" 71 android:layout_height="wrap_content" /> 72 <Button 73 android:layout_width="wrap_content" 74 android:text="重播" 75 style="?android:attr/buttonStyleSmall" 76 android:id="@+id/vv_restart" 77 android:layout_height="wrap_content" /> 78 <Button 79 android:layout_width="wrap_content" 80 android:text="下一个" 81 style="?android:attr/buttonStyleSmall" 82 android:id="@+id/vv_next" 83 android:layout_height="wrap_content" /> 84 85 </LinearLayout> 86 </LinearLayout> 87 </FrameLayout> 88 89 <TextView 90 android:layout_width="wrap_content" 91 android:layout_height="wrap_content" 92 android:textSize="15dp" 93 android:text="点击播放" 94 android:textColor="@color/colorWhite" 95 android:id="@+id/vv_text" 96 android:layout_gravity="center" /> 97 </FrameLayout> 98 </LinearLayout>
View Code
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/bofangqi/article-122936-3.html
这点可以学朝鲜一下下
留言好多托