android動態設定控制元件的大小和位置
本次做的是機頂盒上視訊播放器,當視訊播放控制元件的大小先在xml檔案設定完成。
當點選視訊控制元件時,使視訊為全屏播放,此時
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT , LayoutParams.MATCH_PARENT);
mVideoView.setLayoutParams(layoutParams);
當按返回鍵時
RelativeLayout.LayoutParams layoutVideoParams = new RelativeLayout.LayoutParams((int) 768, (int) 480);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams((int) 788, (int) 500);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
layoutVideoParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mVideoLayout.setLayoutParams(layoutParams);
mVideoView.setLayoutParams(layoutVideoParams);
先設定控制元件的大小,再設定為螢幕居中。
還未研究出根據座標位置設定控制元件的方法