Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the baseline in RelativeLayout?

What does "baseline" refer to when used in the context of a relative layout? Simple question, probably, but the documentation and google offer no hints.

like image 419
David Liu Avatar asked Jun 22 '11 22:06

David Liu


People also ask

What is a baseline in android view?

The term baseline comes from typography. It's the invisible line letters in text sit on. For example, imagine you put two TextView elements next to each other. You give the second TextView a big padding (say 20dp).

What is the default placement of objects in a RelativeLayout?

By default, all child views are drawn at the top-left of the layout, so you must define the position of each view using the various layout properties available from RelativeLayout.

Which is better LinearLayout or RelativeLayout?

Relativelayout is more effective than Linearlayout. It is a common misconception that using the basic layout structures leads to the most efficient layouts. However, each widget and layout you add to your application requires initialization, layout, and drawing.

What is difference between LinearLayout and RelativeLayout?

Android provides the following ViewGroups or layouts: LinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions.


1 Answers

The term baseline comes from typography. It's the invisible line letters in text sit on.

For example, imagine you put two TextView elements next to each other. You give the second TextView a big padding (say 20dp). If you add layout_alignBaseline to the second element, the text will "scoot up" to align with the baseline of the first element. The text from both elements will appear as if they were written on the same invisible line.

<RelativeLayout     android:layout_width="fill_parent"     android:layout_height="fill_parent" >   <TextView       android:id="@+id/text1"       android:text="aatlg"       android:layout_width="wrap_content"       android:layout_height="wrap_content"       />   <TextView       android:text="joof"       android:background="#00ff00"       android:padding="20dp"       android:layout_width="wrap_content"       android:layout_height="wrap_content"       android:layout_toRightOf="@id/text1"       android:layout_alignBaseline="@id/text1"       /> </RelativeLayout> 
like image 103
Cristian Avatar answered Oct 07 '22 05:10

Cristian