【问题标题】:Which is the advantage of using Space over View使用 Space over View 的优势是什么
【发布时间】:2016-08-31 16:53:16
【问题描述】:

我发现我正在使用View 来在我的布局中留出空间,我想用Space 替换它。
所以我问自己用Space 替换View 是否有任何好处来腾出空间。

使用View 小部件的空间:

<View
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        />

使用Space 小部件的空间:

<Space
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        />

那么...在布局中使用Space 视图而不是View 有什么好处?

【问题讨论】:

  • 即使有,我也怀疑它会很重要。不过,这个名称可能会更清楚地说明意图。

标签: android performance view android-view


【解决方案1】:

在大多数情况下,它们完全相同。默认情况下,空间将其可见性设置为View#INVISIBLE,因此会跳过绘图操作。除此之外,没有太大区别。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 2014-08-03
    • 2015-03-05
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    相关资源
    最近更新 更多