Hello! The question is: what needs to be done so that several imagebutton (say, five) located on the same Relativelayout are displayed equally on devices with different screen diagonals, that is, all five buttons are completely visible and not cropped like on the big screen, and on a smaller screen. Thank.

  • one
    I think you need to put dimensions through weight. So it will be proportional to the screen to anyone. In general, the question is too vague, it is difficult to answer. - Yuriy SPb
  • "You, I think, need to put down the dimensions through the weight" - is it possible in more detail? - Vyacheslav161
  • Is it possible to manually make for each screen diagonal that the imagebutton is displayed as I need, i.e. so as not to "crawl" on each other and look the same and proportionally to the size of any screen? - Vyacheslav161

1 answer 1

Use weight - it allows you to set one of the parameters in proportion to the container.

This markup will set each View the same height within the container, i.e. 1/4 screen

<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> </LinearLayout>