Android自定义videoview仿抖音界面的示例分析

  介绍

这篇文章主要介绍Android自定义videoview仿抖音界面的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

Android是什么

Android是一种基于Linux内核的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由美国谷歌公司和开放手机联盟领导及开发。

具体内容如下

1。效果图

和抖音的界面效果一模一样,而且可以自定义,需要什么页面,请自己定义

2。自定义videoview

package  com.example.myapplication20;   ,   ,   import  android.content.Context;   import  android.util.AttributeSet;   import  android.widget.VideoView;   ,      public  class  CusVideoView  extends  VideoView  {   ,,,public  CusVideoView (Context 上下文),{   ,,,,,,,超级(上下文);   ,,,}   ,   ,,,public  CusVideoView (Context 上下文,AttributeSet  attrs), {   ,,,,,,,超级(上下文,attrs);   ,,,}   ,   ,,,public  CusVideoView (Context 上下文,AttributeSet  attrs,, int  defStyleAttr), {   ,,,,,,,超级(上下文,attrs, defStyleAttr);   ,,,}   ,   ,,@Override   ,,,protected  void  onMeasure (int  widthMeasureSpec, int  heightMeasureSpec), {   ,,,,,,,super.onMeasure (heightMeasureSpec widthMeasureSpec也);   ,,,,,,,int  width =, getDefaultSize (getWidth (),, widthMeasureSpec);   ,,,,,,,int  height =, getDefaultSize(获得(),,heightMeasureSpec);   ,,,,,,,setMeasuredDimension(宽度,高度);   ,,,}   }

3。xml界面

& lt; ? xml  version=?.0“,编码=皍tf-8" ?比;   & lt; RelativeLayout  xmlns: android=癶ttp://schemas.android.com/apk/res/android"   ,,,xmlns:应用=癶ttp://schemas.android.com/apk/res-auto"   ,,,xmlns:工具=癶ttp://schemas.android.com/tools"   ,,,android: id=癅 + id/mRootView"   ,,,android: layout_width=癿atch_parent"   ,,,android: layout_height=癿atch_parent"比;   ,   ,,,& lt; ImageView   ,,,,,,,android: id=癅 + id/mThumb"   ,,,,,,,android: layout_width=癿atch_parent"   ,,,,,,,android: layout_height=癿atch_parent"   ,,,,,,,android:点击=癴alse"   ,,,,,,,android: focusable=癴alse"   ,,,,,,,android: scaleType=癱enterCrop"   ,,,,,,,android:可见性=皏isible",/比;   ,   ,,,& lt; ImageView   ,,,,,,,android: id=癅 + id/mPlay"   ,,,,,,,android: layout_width=?00 dp"   ,,,,,,,android: layout_height=?00 dp"   ,,,,,,,android: layout_centerInParent=皌rue"   ,,,,,,,android:α=?”;   ,,,,,,,android:点击=皌rue"   ,,,,,,,android: focusable=皌rue"   ,,,,,,,android: src=https://www.yisu.com/zixun/" @drawable/play_arrow "/>                  LinearLayout         

4。可拉的

& lt; vector  android:α=?.61“,android:身高=?4 dp"   ,,,android: viewportHeight=?4.0“, android: viewportWidth=?4.0”;   ,,,android:宽度=?4 dp", xmlns: android=癶ttp://schemas.android.com/apk/res/android"比;   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

Android自定义videoview仿抖音界面的示例分析