I am trying to make empty lines within android. This is what I have been doing:
android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="\n\n"
I want to know if there is a better way? Thanks
To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1" .
Layout is interwoven with other fundamental principles of graphic design, such as color, contrast, repetition, texture, and typography. Layout design also encapsulates the principles of hierarchy, balance, alignment, proximity, and space.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With