2012-01-24 65 views
0

如何從一個LinearLayout複製參數並將其設置爲另一個LinearLayout代碼? 我試圖像如何從一個LinearLayout中複製參數並在代碼中設置爲另一個LinearLayout?

LinearLayout.LayoutParams paramsR=(LinearLayout.LayoutParams) llRight.getLayoutParams(); 
LinearLayout.LayoutParams paramsL=(LinearLayout.LayoutParams) llLeft.getLayoutParams(); 
paramsR.height=paramsL.height; 
paramsR.width=paramsL.width; 
llRight.setLayoutParams(paramsR); 

,但它忽略的。如何解決這個問題呢 ?

回答

-3

如果llRight & llLeft父是RelativeLayout那麼你應該使用:

RelativeLayout.LayoutParams paramsR=(RelativeLayout.LayoutParams) llRight.getLayoutParams(); 
RelativeLayout.LayoutParams paramsL=(RelativeLayout.LayoutParams) llLeft.getLayoutParams(); 
paramsR.height=paramsL.height; 
paramsR.width=paramsL.width; 
llRight.setLayoutParams(paramsR); 
相關問題