前文: 

桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 1

导航:

桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The End 导航页及收尾工作

2.视频背景

(1)在res文件夹下新建raw文件夹。

(2)将准备好的视频素材放入raw文件夹。

(3)进行UI布局和代码处理。

activity_main.xml 

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><VideoViewandroid:id="@+id/video_background"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentStart="true"android:layout_alignParentTop="true"android:layout_alignParentEnd="true"android:layout_alignParentBottom="true"android:alpha="1"tools:layout_editor_absoluteX="0dp"tools:layout_editor_absoluteY="0dp" /></androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java 

 package com.example.peachdictionary;import androidx.appcompat.app.AppCompatActivity;import android.content.pm.ActivityInfo;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.VideoView;public class MainActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//设置此界面为竖屏setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);videobackground();}private void videobackground() {//视频背景final VideoView videoview = findViewById(R.id.video_background);final String videopath = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.background).toString();videoview.setVideoPath(videopath);videoview.start();videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {@Overridepublic void onPrepared(MediaPlayer mp) {mp.start();mp.setLooping(true);}});videoview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {@Overridepublic void onCompletion(MediaPlayer mediaPlayer) {videoview.setVideoPath(videopath);videoview.start();}});}}

实现效果:

桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 2相关推荐

  1. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 4

    前文: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 3 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The E ...

  2. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 7

    前文: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 6 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The E ...

  3. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 8

    前文: ​​​​​​桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 7 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 ...

  4. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The End 导航页及收尾工作

    导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 1 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 2 桃词 ...

  5. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 1

    前言 由于笔者操作不当,将项目搞崩了,所以打算重写一遍,记下开发过程,作为学习记录.此软件能实现最普通的单词查询功能,也有启动动画.登录注册之类的功能,但笔者目前能力有限,未能将其完善,这是初学阶段的 ...

  6. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 9

    前文: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 8 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The E ...

  7. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 3

    前文: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 2 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The E ...

  8. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 5

    前文: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 4 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The E ...

  9. 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 6

    前文: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 Part 5 导航: 桃词典 Peach Dictionary 简易英语词典app开发 安卓软件开发 The E ...

最新文章

  1. linux正则表达式sed
  2. tmux的使用方法和个性化配置
  3. 数据可视化配色指南:三大配色方法,做出咨询报告一样的图表丨附在线工具资源...
  4. 每输入四个字符添加一个中划线
  5. 做好计划事半功倍论文_Picocli 2.0:事半功倍
  6. 一张图说明我们为什么要关注 HTML5
  7. windows上怎么干净彻底的卸载oracle
  8. 初学者python笔记(map()函数、reduce()函数、filter()函数、匿名函数)
  9. 和老公去出吃饭,每次我出钱。这样正常吗?
  10. oracle本地没装 配置,数据库--oracle安装配置(本地安装的步骤及各种问题解决方案)...
  11. lastLogon和lastLogonTimestamp的区别
  12. Ubuntu18.04安装npm失败解决
  13. 基于单片机的自动加热水壶控制器代码_应用于实时温度控制的单片机设计
  14. 一种常见(粒度,统计值)报表的实现方案
  15. Improving Opencv 2:The Core Functionality :How to scan images, lookup tables
  16. keycloak授权流程详解
  17. 腾讯公司执行董事 董事会主席兼本公司首席执行官 马化腾
  18. sai笔记1-sai安装
  19. 电脑主机插入耳机无声音
  20. dc是什么游戏的简称_游戏缩写简称

热门文章

  1. 重装也无法修复此计算机,无法重装系统解决方法
  2. iframe标签控制视频大小及自动播放
  3. android 播放多个音频文件,android – 如何同时播放多个ogg或mp3 ..?
  4. python面向对象编程
  5. matlab中sqp的算法原理_最优化方法及其Matlab程序设计 马昌凤
  6. 鸿蒙系统翻车了,华为鸿蒙系统“翻车了”?被质疑抄袭安卓11系统,事实并非如此...
  7. java倒序输出英文句子_java逆序英文句子中的单词顺序
  8. Android仿淘宝、京东Banner滑动查看图文详情
  9. 微信应用域名所有权验证管理
  10. html语言怎么在虚线中加字,html – 用CSS添加虚线spacer / infill