PowenKo, Android Tutorial 10-3, TextView, ‘gravity’ property

November 22, 2011   ·   0 Comments

Example for Android textview alignment -

To align a textview we need to use the ‘gravity’ property

<TextView android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center" />

Now we set the alignment to center so that textview text will appear in the center of the textview(see the below image).

textviewaligmentcenter

We can set the gravity as top, right, left, bottom,etc…you can also set more than one gravity at a time.

For instance,

android:gravity=”right|center”

textviewalignmentcenterright

(Note: The red color lines won’t appear in the output.)

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon