获取屏幕尺寸
WindowManager wm = this.getWindowManager();
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
设置控件大小
ViewGroup.LayoutParams lp;
lp = ll_gesture.getLayoutParams();
lp.width = width;
lp.height = hidth;
ll_gesture.setLayoutParams(lp);
简单快速屏幕适配https://www.jianshu.com/p/b6b9bd1fba4d/
上面有可能过期了哦用用下面
//侧滑
mDlmaindrawer = (DrawerLayout) findViewById(R.id.dl_main_drawer);
WindowManager wm = this.getWindowManager();//获取屏幕宽高
Display dis = wm.getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
dis.getMetrics(dm);
int width1 = dm.widthPixels/3*2;
int height1 = dm.heightPixels;
LinearLayout.LayoutParams para= new LinearLayout.LayoutParams(width1,height1);
leftLayout = (LinearLayout) findViewById(R.id.left_layout);
leftLayout.setLayoutParams(para); //设置修改后的布局。