我需要添加功能以全屏查看我的视频。
Videoview 是否只在他的控制面板上提供 3 个按钮 (<<) (>) (>>),因为它可以添加第四个按钮以全屏显示视频?
要全屏查看视频,只需将嵌入的布局参数更改为 fill_parent。
有任何想法吗?
谢谢
我需要添加功能以全屏查看我的视频。
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);