Android 调整视频视图大小时出错
我在 main.xml 文件的 FrameLayout 中使用 VideoView。 我希望能够动态调整 VideoView 的大小,以最小化/隐藏它 屏幕。我不想更改它的可见性,因为它会导致运行我的游戏的另一个线程出现问题/崩溃。
这是代码
VideoView vv;
ViewGroup.LayoutParams params;
vv = (VideoView) findViewById( R.id.gmVideo );
params = vv.getLayoutParams();
params.width = gm.StoreX;
params.height = gm.StoreY;
vv.setLayoutParams(params);
我收到的错误消息是
Only the original thread can touch this view
有没有办法修改代码中的 VideoView 尺寸而不崩溃破坏系统。 或者活动或其他代码中是否只有某些位置可以在不违反访问限制的情况下进行修改。
I am using a VideoView in a FrameLayout in my main.xml file.
I would like to be able to dynamically resize the VideoView as to minimize/hide it from
the screen. I do not wish to change it's visibility as it will cause problems/crash with another thread which is running my game.
Here is the code
VideoView vv;
ViewGroup.LayoutParams params;
vv = (VideoView) findViewById( R.id.gmVideo );
params = vv.getLayoutParams();
params.width = gm.StoreX;
params.height = gm.StoreY;
vv.setLayoutParams(params);
The error message i receive is
Only the original thread can touch this view
Is there a way to modify the VideoView dimensions in code without crashing disrupting the system.
OR Is there only certain places in the Activity or other code in which the modifications can be made without violating access restrictions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用这种方式,
另请阅读何时以及为何使用 runOnUIThread() 此处< /a>..
Try using this way,
also read when and why to use runOnUIThread() here..