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) –