In android development, some controls are often dynamically generated and their layout is adjusted. For details about how to dynamically adjust the layout of a space, refer to the following key code:
MRlMain = (RelativeLayout) findViewById (R. id. rlMain );
LayoutParams layoutParams = new LayoutParams (
Android. view. ViewGroup. LayoutParams. WRAP_CONTENT,
Android. view. ViewGroup. LayoutParams. WRAP_CONTENT );
MBtnView = LayoutInflater. from (mContext). inflate (R. layout. photoright, null );
LayoutParams. addRule (RelativeLayout. CENTER_VERTICAL, RelativeLayout. TRUE );
LayoutParams. addRule (RelativeLayout. ALIGN_PARENT_RIGHT, RelativeLayout. TRUE );
MRlMain. addView (mBtnView, layoutParams );
The main classes used are android. widget. RelativeLayout. LayoutParams, android. view. ViewGroup. LayoutParams, and android. widget. RelativeLayout.
The above mainly uses relative layout settings. Other layout methods are similar.
From the column of the pure soul