gpt4 book ai didi

android - VideoView 闪烁问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:01 24 4
gpt4 key购买 nike

我在使用 VideoView 时遇到了奇怪的闪烁问题。当 Activity 开始时,它会导致一秒钟的轻微闪烁。然后,视频开始。它在视频的顶部和底部显示 2 条黑线。请参阅下面的快照。

check snap shot

我已经在 2 台设备上测试了我的应用程序

1) 三星n-8000(平板)

2)联想a-800

video.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:gravity="center">

<VideoView
android:id="@+id/vvSplash"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#00ffffff">
</VideoView>

</LinearLayout>

Activity 代码:

private VideoView vd;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.video);
vd = (VideoView) findViewById(R.id.vvSplash);
playVideo();
}

private void playVideo() {
Uri uri = Uri.parse("android.resource://" + getPackageName() +"/"+ R.raw.intro);
vd.setVideoURI(uri);
vd.setMediaController(null);
vd.start();
}

如有任何帮助,我们将不胜感激。谢谢你。

最佳答案

虽然听起来很荒谬,但答案就在这里:

我重复这个解决方案,感谢那些发现的人:

<SurfaceView
android:layout_width="0px"
android:layout_height="0px"
android:visibility="gone" />

非常重要将表面 View 添加到 Activity 中的 Root View ,而不是直接父 View 。否则它不会工作。

关于android - VideoView 闪烁问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17587476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com