how to set height of relative layout dynamically in android

孤街醉人 提交于 2019-12-01 06:19:26

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.......

You should not use px, use dp instead.

android:layout_height="365dp"

Have a read here, to know Density independent pixel(dp) better.

Using dp units to define your application's UI is highly recommended, as a way of ensuring proper display of your UI on different screens.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!