• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Issue with Gravity/Centering

Below is the code...

Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[URL]http://schemas.android.com/apk/res/android[/URL]"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF">
    
    
    <TextView
     android:layout_width="fill_parent"
     android:id="@+id/tvJoke"
     android:layout_height="wrap_content"
     android:layout_marginTop="20dip"
     android:layout_marginLeft="10dip"
     android:textColor="#000000"
    /> 
    
    <LinearLayout
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     [B]   android:gravity="bottom"
[/B]     android:layout_below="@id/tvJoke">
     
  <Button 
   android:text="prev"
   android:layout_height="wrap_content" 
   android:layout_width="100px"
   android:id="@+id/btnPrevious">
  </Button>
  <Button 
   android:text="share" 
   android:id="@+id/btnMessage" 
   android:layout_width="100px" 
   android:layout_height="wrap_content">
  </Button>
  <Button 
   android:text="next" 
   android:layout_height="wrap_content" 
   android:layout_width="100px"
   android:id="@+id/btnNext">
  </Button>
</LinearLayout>
</RelativeLayout>

When I set the gravity in the Linear Layout to Bottom, the three buttons go to the bottom, but they are not horizontally centered. If I set the gravity to center_horizontal, the buttons are no longer aligned against the bottom of the screen - and they shouldn't be in this case...

My question is what is the solution to horizontally center the buttons as well as aligning them toward the bottom?

It would be nice if there was a gravity = "horizontal_center, bottom" -- two options

Any help is much appreciated...
 
Back
Top Bottom