[XML-Layouts] - Useful Snippets

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

[XML-Layouts] - Useful Snippets

Postby plusminus » Mon Dec 17, 2007 8:24 pm

[align=center]Useful XML-Layouting Snippets[/align]

Centering Views within its parent:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:gravity="center_horizontal"
Parsed in 0.000 seconds, using GeSHi
Java equivalent:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setGravity(Gravity.CENTER_VERTICAL);
Parsed in 0.031 seconds, using GeSHi

Remember the difference between:
Code: Select all
* android:gravity will center the text within the TextView.
* android:layout_gravity will center the TextView within its parent.

For more info see:
http://code.google.com/android/referenc ... id:gravity[hr][hr]

Image | Android Development Community / Tutorials
User avatar
Site Admin
Site Admin
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany


Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests