Results 1 to 2 of 2
  1. #1
    Niv99 is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default android:layout_gravity not working

    hello.
    i watched The new boston's tutorials and he wrote "android:layout_gravity="center" and then the text moved to the center.
    i copy what he did and it don't work for me.

    this is the code:
    RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world"
    android:textSize="45dp"
    android:layout_gravity="center"
    />

    </RelativeLayout>


    i also tried android:gravity="center" and it didnt work.

    what i did wrong and how can i fix it?

    and sorry for the bed english

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: android:layout_gravity not working

    I can never keep the gravity tags straight. Did you try putting layout_gravity in the layout instead of the view? If that fails, try looking up the documentation for those tags. I have to refer to it every time I use them.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Android Locale in not working on text to speech
    By raj.mscking@gmail.com in forum Android
    Replies: 2
    Last Post: 12-29-2013, 05:48 PM
  2. Replies: 10
    Last Post: 11-23-2013, 06:47 PM
  3. Replies: 1
    Last Post: 12-24-2011, 04:41 AM
  4. Replies: 2
    Last Post: 01-04-2011, 04:30 AM
  5. Replies: 8
    Last Post: 05-28-2008, 07:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •