开发者

Android - How to place an item on a layout relatively to the top?

开发者 https://www.devze.com 2023-03-09 19:02 出处:网络
How could I proceed to place an item on a LinearLayout, with a given space from the top? For instance, I would like to pla开发者_Python百科ce the logo on the half of the top middle of the layout.

How could I proceed to place an item on a LinearLayout, with a given space from the top? For instance, I would like to pla开发者_Python百科ce the logo on the half of the top middle of the layout.

Thanks


There is no way to add percentages.

  • You can add two layouts with the same weight to split the screen in two and then add the logo with a centered gravity to the upper layout,

  • Or you can measure the screen and add the right amount of margins.


Use the paddingTop attribute of the view class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号