how to set height of relative layout dynamically in android

前端 未结 2 1768
[愿得一人]
[愿得一人] 2021-01-13 08:35

This is working fine on emulator but not on the devices because I have hard coded the height to 365. Can anyone help me in this regard?



        
2条回答
  •  春和景丽
    2021-01-13 08:55

    You can change the layout height dynamically through different ways-----

    First,

    getLayoutParams().height= x;
    requestLayout(); or invalidate(); 
    

    Secondly,

     first_tab.setHeight(int pixels);
    

    Try using anyone of the way.......

提交回复
热议问题