得到设备屏幕宽高:
WindowManager wManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Display display = wManager.getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight();
设置View大小:
LayoutParams lp = mView.getLayoutParams(); lp.width = width/2; lp.height = height/3; mView.setLayoutParams(lp);