how to set height of relative layout dynamically in android

前端 未结 2 1766
[愿得一人]
[愿得一人] 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 09:00

    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.

提交回复
热议问题