[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]

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

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]

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

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: Google [Bot] and 10 guests