VideoView in different screen sizes

谁说胖子不能爱 提交于 2019-12-04 15:52:16

A Drawable, as far as Android is concerned is any kind of graphic/image/icon... But a video doesn't fall in that category. For that matter, you'll have to place it at the "./assets/" folder. Therefore, videos aren't automatically selected according to the screen size.

However, even if the videos are in a different folder, you can load them programmatically at the onCreate() method, like this:

Display mDisplay = getWindowManager().getDefaultDisplay(); 
int w = mDisplay.getWidth();
int h = mDisplay.getHeight();

if (w < 480 || h < 800) {
    mVideoView.setVideoPath(...your video in assets, of low resolution...);;
} else {
    mVideoView.setVideoPath(...your video in assets, of high resolution...);
}
...

With this or a similar method, you can load different videos, according to the user resolution, in a way that is even more precise than the ldpi/mdpi/etc method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!