Amokrane Chentir
Amokrane Chentir

Reputation: 30385

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 place the logo on the half of the top middle of the layout.

Thanks

Upvotes: 0

Views: 93

Answers (2)

Phiper
Phiper

Reputation: 11

Use the paddingTop attribute of the view class.

Upvotes: 1

Aleadam
Aleadam

Reputation: 40381

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.

Upvotes: 1

Related Questions