How to make the dimension of a button relative to the screen size?

3129 views android

How can I make the width of a button so that it is, for example, a quater of the screen, or a fifth?

answered question

please your question

1 Answer


Take the width of the screen and divide it by 2 (so you have the half of the screen width) and then again by 2 to get the quarter of the screen width:

button_width = (screen_width/4)

posted this

Have an answer?


Please login first before posting an answer.