Adding blank spaces to layout
Use Space
or View
to add a specific amount of space. For 30 vertical density pixels:
<Space
android:layout_width="1dp"
android:layout_height="30dp"/>
If you need a flexible space-filler, use View
between items in a LinearLayout
:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
or
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_weight="1"/>
This works for most layouts for API 14 & later, except widgets (use FrameLayout
instead).
[Updated 9/2014 to use Space. Hat tip to @Sean]
If you don't need the gap to be exactly 2 lines high, you can add an empty view like this:
<View
android:layout_width="fill_parent"
android:layout_height="30dp">
</View>