// 将列表中的每个视频设置为默认16:9的比例
ViewGroup.LayoutParams params = mVideoPlayer.getLayoutParams();
params.width = itemView.getResources().getDisplayMetrics().widthPixels; // 宽度为屏幕宽度
params.height = (int) (params.width * 9f / 16f); // 高度为宽度的9/16
ViewGroup.LayoutParams params = mVideoPlayer.getLayoutParams();
params.width = itemView.getResources().getDisplayMetrics().widthPixels; // 宽度为屏幕宽度
params.height = (int) (params.width * 9f / 16f); // 高度为宽度的9/16
mVideoPlayer.setLayoutParams(params);
RelativeLayout.LayoutParams layoutParams=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); layoutParams.width = wm.getDefaultDisplay().getWidth(); layoutParams.height = (int) (layoutParams.width* 9f / 16f);//16:9 System.out.println("宽度=="+layoutParams.width+",高度=="+layoutParams.height); bannerView.setLayoutParams(layoutParams);