注意:在調用getLayoutParams()方法時,這個layoutparams的類型,取決於它的父view,如果父view是FrameLayout,那麼就是FrameLayout.LayoutParams ,如果是RelativeLayout,那麼就是RelativeLayout.LayoutParams。。。其他的如LinearLayout也一樣
DisplayMetrics dm = getResources().getDisplayMetrics();
if (dm != null) {
screenWidth = dm.widthPixels;
screenHeight = dm.heightPixels;
}
int webviewWidth = (int)(screenWidth * (405.0/375.0));
int cancelWidth = screenHeight - webviewWidth;
LinearLayout.LayoutParams cancelParams = (LinearLayout.LayoutParams) mNineBoxCancelView.getLayoutParams();
cancelParams.width = cancelWidth;
mNineBoxCancelView.setLayoutParams(cancelParams);
LinearLayout.LayoutParams webviewParams = (LinearLayout.LayoutParams) mNineBoxWebview.getLayoutParams();
webviewParams.width = webviewWidth;
mNineBoxWebview.setLayoutParams(webviewParams);