Change Relative layout width and height dynamically

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

Hi i am using following layout structure inside LinearLayout



        
7条回答
  •  悲哀的现实
    2020-12-14 09:45

    You can set views dimensions dynamically using LayoutParams. Something like this:

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.yourlayout_id);
    // Gets the layout params that will allow you to resize the layout
    LayoutParams params = layout.getLayoutParams();
    params.height = 320;
    params.width = 320;
    

提交回复
热议问题