2012-09-05 19 views
0

我有一个关于调整大小布局的问题。这是我的活动:更改android中的代码大小布局

@Override 
protected void onCreate(Bundle savedInstanceState) { 


    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 

    requestWindowFeature(Window.FEATURE_ACTION_BAR); 
    setContentView(R.layout.log_in); 


} 

如何在此活动中设置大小我的R.layout.log_in?我想将尺寸设置为400x300,但是在活动中不是xml。

回答

0

我不知道你的要求是什么,但我更喜欢在xml上设置维度(如果它们被假定为固定的话)。

无论如何,this会很有用。

在链路中使用的代码:

// Gets linearlayout 
LinearLayout layout = (LinearLayout)findViewById(R.id.numberPadLayout); 
// Gets the layout params that will allow you to resize the layout 
LayoutParams params = layout.getLayoutParams(); 
// Changes the height and width to the specified *pixels* 
params.height = 300; 
params.width = 400;