Change Relative layout width and height dynamically

后端 未结 7 1153
眼角桃花
眼角桃花 2020-12-14 09:30

Hi i am using following layout structure inside LinearLayout



        
7条回答
  •  死守一世寂寞
    2020-12-14 09:59

    give an id to your relative layout in .xml :

    android:id="@+id/relativelayout"
    

    now in your java file write this:

    RelativeLayout Rl = (RelativeLayout) findViewById(R.id.relativelayout);
    
    RelativeLayout.LayoutParams layout_description = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT or YourUserDefinedwidth,
                            RelativeLayout.LayoutParams.FILL_PARENT or YourUserDefinedHeight);
    
    Rl.setLayoutParams(layout_description);
    

提交回复
热议问题