6

Currently I'm creating a button with Image and Text. My problem is I want to move the text to teh buttom of the button.

<Button
  android:layout_weight=".30" 
  android:layout_margin="2dp" 
  android:background="@drawable/btnforgot" 
  android:layout_height="60dp" 
  android:layout_width="100dp" 
  android:text="Forgot "/>

Hope someone can help me out in this regard. Searched many places but couldn't come up with a solution.

Thanks in advance.

Paresh Mayani
  • 125,853
  • 70
  • 238
  • 294
Jay Mayu
  • 16,523
  • 31
  • 112
  • 147

4 Answers4

29

Simply add android:gravity="bottom|center" to your Button declaration. If you want to lift it from the bottom slightly, then add android:paddingBottom="4dp" as well.

Mark Allison
  • 21,740
  • 8
  • 45
  • 45
1

I am not sure but android:gravity="bottom" can be helpful to you. Try this inside the <Button>.

Update:

If you want to know about android:gravity and android:layout_gravity then just check this SO question: Gravity and layout_gravity on Android

Community
  • 1
  • 1
Paresh Mayani
  • 125,853
  • 70
  • 238
  • 294
0

try android:layout_gravity="bottom" and android:gravity="bottom" properties....it will work.

Krishna
  • 1,454
  • 5
  • 16
  • 31
  • 1
    android:layout_gravity sets the gravity of the View or Layout in its parent. For more info: http://stackoverflow.com/questions/3482742/android-gravity-and-layout-gravity/3482757#3482757 – Paresh Mayani Jul 27 '11 at 08:43
  • 1
    oh yeah rite.. a bit confused between both. – Krishna Jul 27 '11 at 08:52
0

Try with this :

android:layout_weight="0"

It works for me.

hardartcore
  • 16,656
  • 11
  • 72
  • 98