Linear Layout baselinealigned warning on android

前端 未结 2 1159
粉色の甜心
粉色の甜心 2021-02-05 17:24

i am getting \"Set android:baselineAligned=\"false\" on this element for better performance\" while using LinearLayout, I know its regarding performance,but i dont know exactly

相关标签:
2条回答
  • 2021-02-05 17:47

    If you are looking for a visual explanation like me, then you might find this useful.

    When baselineAlign is enabled(i.e if it is set to true), then all the text in that line will be aligned to have the same baseline.

    Note: By default, baselineAligned is set to true. (i.e. baselineAligned=true)

    When you make baselineAligned=false, all it needs to do is to add new elements to the linear layout and be done with it. The app need not worry about where the baseline of other elements in the layout is.

    See the image below for more clarity

    0 讨论(0)
  • 2021-02-05 17:52

    android:baselineAligned/setBaselineAligned(boolean): When set to false, prevents the layout from aligning its children's baselines.

    So can take example with linear layout with horizontal child views having multiple TextView with different text size or different views like button there basealignment would be different and you cannot adjust it to have same basealignment if you set it to false

    Reference

    Update: By setting android:baselineAligned="false" , you're preventing the extra work your app's layout has to do in order to Align its children's baselines; which can obviously increase the performance. (Less unnecessary operations on UI => Better performance) as mentioned here

    0 讨论(0)
提交回复
热议问题