在android中更改代码中的大小布局

在android中更改代码中的大小布局,android,android-layout,Android,Android Layout,我有一个关于调整布局的问题。这是我的活动: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView

我有一个关于调整布局的问题。这是我的活动:

@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_的大小?我想将大小设置为400x300,但在活动中不是xml。

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

无论如何,这可能是有用的

链接中使用的代码:

// 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;