How does setting baselineAligned to false improve performance in LinearLayout?

后端 未结 3 923
青春惊慌失措
青春惊慌失措 2020-12-22 19:22

I was just building some UI in xml, and Lint gave me a warning and said to set android:baselineAligned to false to improve performance in ListView.

The docs for the

3条回答
  •  爱一瞬间的悲伤
    2020-12-22 20:17

    how android:baselineAligned="false" help . It may not be the answer but help to get concept.

    I've just managed to get 3 items (icon, text, button) centered vertically in horizontal LinearLayout.

    This may seem simple, but in reality specifying android:gravity="center_vertical" as LinearLayout attribute is not enough - icon is centered, but text and button are not. This is because (presumably) text have a baseline, and centering algorithm uses it instead of 'real' vertical center. But what is worse - button (which comes next to text) is centered using text's baseline!

    Specifying android:baselineAligned="false" in LinearLayout turns this off, and everything centers correctly.

提交回复
热议问题