【问题标题】:CardView - layout_height="wrap_content" or const value - performance impact?CardView - layout_height="wrap_content" 或 const value - 性能影响?
【发布时间】:2016-12-31 19:57:49
【问题描述】:

我有RecyclerViewCardViews。如果我在CardView 中设置layout_height="wrap_content" 而不是layout_height="const_value_dp",我的列表会运行得更慢吗?

【问题讨论】:

    标签: android listview android-recyclerview android-cardview listviewitem


    【解决方案1】:

    不,wrap_content 不应该比constant_value_dp 对性能产生任何影响,这是程序员的唯一选择。

    【讨论】:

    • 你有这方面的资料吗?
    【解决方案2】:

    有一件事是肯定的, 如果您在其父布局中使用带有 weightSum 的 layout_height="0dp"layout_width="0dp",则会导致性能不佳。

    布局权重需要对小部件进行两次测量。当一个权重非零的 LinearLayout 嵌套在另一个权重非零的 LinearLayout 中时,测量次数会呈指数增长。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-14
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 2016-05-17
      • 2015-04-08
      • 1970-01-01
      相关资源
      最近更新 更多