Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding blank spaces to layout

Tags:

android

xml

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

like image 957
Qwertyfshag Avatar asked Jun 15 '11 01:06

Qwertyfshag


People also ask

How do you add a space in linear layout?

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" .

What does a layout contain?

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.


1 Answers

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]

like image 147
radley Avatar answered Sep 24 '22 00:09

radley