开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜