gpt4 book ai didi

android - 在全屏视频上添加全屏按钮

转载 作者:行者123 更新时间:2023-11-29 00:33:35 27 4
gpt4 key购买 nike

我需要添加功能以全屏观看视频。

Videoview的控制面板上是否仅提供3个按钮(<<)(>)(>>),因为它可以添加第四个按钮以全屏显示视频?

要全屏观看视频,只需将嵌入视频的布局参数更改为fill_parent。

有任何想法吗?

谢谢

最佳答案

最后,我通过将按钮手动添加到“相对布局”中来解决了该问题:

LinearLayout lLinLayout = new LinearLayout(this);
lLinLayout.setId(1);
lLinLayout.setOrientation(LinearLayout.VERTICAL);
lLinLayout.setGravity(Gravity.CENTER);
lLinLayout.setBackgroundColor(Color.BLACK);

LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
lLinLayout.setLayoutParams(lLinLayoutParms);

this.setContentView(lLinLayout);


RelativeLayout lRelLayout = new RelativeLayout(this);
lRelLayout.setId(2);
lRelLayout.setGravity(Gravity.CENTER);
lRelLayout.setBackgroundColor(Color.BLACK);
android.widget.RelativeLayout.LayoutParams lRelLayoutParms =
new android.widget.RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
lRelLayout.setLayoutParams(lRelLayoutParms);
lLinLayout.addView(lRelLayout);

mVideoView = new VideoView(this);
mVideoView.setId(3);
android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams =
new android.widget.RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mVideoView.setLayoutParams(lVidViewLayoutParams);
lRelLayout.addView(mVideoView);

Button myButton = new Button(this);
myButton.setId(3);
android.widget.RelativeLayout.LayoutParams buttonParams =
new android.widget.RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
buttonParams.addRule(RelativeLayout.CENTER_IN_PARENT);
myButton.setLayoutParams(buttonParams);
myButton.setText("My Button!");
lRelLayout.addView(myButton);

关于android - 在全屏视频上添加全屏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13948100/

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