2

I always set height to 50dp,but still occur this warningenter image description here

  • Set `layout_height` instead of just `height`. If you want to know the difference, see [this post](https://stackoverflow.com/questions/17391055/whats-the-difference-between-androidheight-and-androidlayout-height) – Ricky Mo Dec 30 '21 at 07:26

1 Answers1

0

If the view is a part of ViewGroup, then the height will be set according to the layout rules. Since you are already bounding height to 50dp, it may cause an error in the runtime.

So the solution is to use layout_height.

WHY?

When using layout_height, it becomes a part of android.view.ViewGroup. It sets a rule. If needed it can resize the height. So its always better to user layout_height.

Moreover, one can use android:maxHeight or android:minHeight to set bounds to the attribute.

Abhishek Dutt
  • 1,308
  • 7
  • 14
  • 24