0
在下面的代碼中,爲什麼我無法爲我的relativeLayout
對象設置自定義尺寸?我的設備的分辨率爲240 * 320。爲什麼我無法爲我的relativeLayout對象設置自定義尺寸
RelativeLayout relativeLayout;
@Override
protected void onCreate(Bundle bundle){
super.onCreate(bundle);
relativeLayout = new RelativeLayout(this);
relativeLayout.getLayoutParams().width=240;
relativeLayout.getLayoutParams().height=320;
setContentView(relativeLayout);}
爲什麼不使用MATCH_PARENT? –
我可以使用'match_parent'。但我想要這個問題的科學原因。 – and
http://stackoverflow.com/questions/3224193/set-the-layout-weight-of-a-textview-programmatically並確保你的屏幕尺寸實際上是240px(而不是dp) –