应用程序加载时的全屏横向视频(启动画面)
我已经在 Android 上摆弄了一个多星期了,知道了相当多的知识,但仍然缺乏大量的知识。我正在尝试使用 mp4 作为启动画面电影活动。我被告知使用的方法都给我带来了可怕的效果。我想要一部全屏水平/横向电影,设备上除了电影之外什么都没有……没有视频控件等。我还希望视频能够被点击和销毁。如果您能提供帮助,我将非常感谢您的努力。
I have been messing around with android for a little over a week now and know a fair amount, yet still lack a ton of knowledge. I am trying to use an mp4 as a splash screen movie activity. And the methods I was told to use all give me a horrible effect. I want a fullscreen horizontal/landscape movie with nothing on the device except the movie...no video controls etc.. I also want the video to be able to be clicked on and destroyed. If you could help I would greatly appreciate any efforts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我设法做到了这一点,下面给出的是我的代码。首先列出的是 Activity,然后给出布局。
该活动在清单文件中声明如下:
如您所见,方向设置为横向,因此启动屏幕将始终以横向模式显示。将此 Activity 的主题设置为 @android:style/Theme.NoTitleBar.Fullscreen 很重要。它使视频覆盖整个屏幕。重要的是要了解 Android 无法将视频缩放到显示器分辨率。因此,如果您的视频分辨率与设备的分辨率不匹配,您将在视频的左/右或顶部/底部看到黑色边框 - 具体取决于您的视频分辨率。
布局文件splash.xml的内容如下:
I managed to do this and given below is my code for it. First listed is the Activity and later the layout is given.
The activity is declared in the manifest file as follows:
As you can see the orientation is set to landscape so the splash screen will always appear in landscape mode. Setting the theme of this activity to @android:style/Theme.NoTitleBar.Fullscreen is important. It makes the video to cover the whole screen. It is important to understand that Android cant scale your video to the displays resolution. So if your videos resolution does not match the device's resolution, you will see black borders to left/right or top/bottom of the video - depending on your videos resolution.
The contents of the layout file splash.xml are given below:
不要对包名称进行硬编码。
相反你可以这样做
"android.resource://" + getPackageName() + "/"+R.raw.VideoName
Dont hardcode the package name.
Instead you could do this
"android.resource://" + getPackageName() + "/"+R.raw.VideoName