0

I have a question about resize layout. This is my activity:

@Override
protected void onCreate(Bundle savedInstanceState) {


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

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


}

How can I set size my R.layout.log_in in this activity? I want set size to 400x300 but in activity not xml.

user1302569
  • 7,131
  • 13
  • 46
  • 66

1 Answers1

0

I don't know what are your requirements but I prefer to set the dimension on the xml (if they're suppose to be fixed).

Anyway, this can be useful.

The code used in the link:

// 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;
Community
  • 1
  • 1
Enrichman
  • 11,157
  • 11
  • 67
  • 101