18

I found that I'm using a View to make the space in my layouts and I thought to replace it with a Space.
So I asked myself if is there any gain to replace View with Space to make the space.

Space using the View widget :

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

Space using the Space widget:

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

So... is there any gain to use the Space view instead of the View for spacing in a layout?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
TooCool
  • 10,598
  • 15
  • 60
  • 85
  • 2
    Even if there was, I DOUBT it would be significant. The name may clarify the intent more clearly though. – Shaishav Aug 31 '16 at 16:54

1 Answers1

21

For the most part, they're exactly the same. A Space sets its visibility to View#INVISIBLE by default so drawing operations are skipped. Other than that, there isn't much of a difference.

DeeV
  • 35,865
  • 9
  • 108
  • 95