Sobes.tech
Junior

How to make a view scale depending on the occupied space (flexible layouts)?

sobes.tech AI

Answer from AI

Use ConstraintLayout with 0dp constraints (MATCH_CONSTRAINT) for width/height and layout_constraintHorizontal_bias / layout_constraintVertical_bias. You can also use LinearLayout with weights (layout_weight).

Other approaches:

  • RecyclerView / ListView with different item types.
  • FlexboxLayout from Google.
  • Programmatically calculate sizes in onCreate or onMeasure.