Reputation: 4480
In the xml I am trying to get the button to be on the right side. Here is my code.
<TableRow>
<Button
android:layout_gravity="right"
android:gravity="right"
android:id="@+id/Button01"
android:text="Sign in" />
</TableRow>
When I delete the tableRow tags, the button goes the entire width of the screen. I also played around with changing right to left and have still had no luck
Upvotes: 1
Views: 10792
Reputation: 754
This worked for me with in a Frame Layout:
android:layout_gravity="right"
for bottom and right try this:
android:layout_gravity="bottom|right"
Upvotes: 3
Reputation: 31284
You're missing width and height parameters for your Button
. Add these to your button tag:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Also, layout_gravity
will only apply in a LinearLayout
or FrameLayout
. If you're in a RelativeLayout
, use android:layout_alignParentRight="true"
Upvotes: 1
Reputation: 5761
can you change the layout?
Try with:
<TableRow>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button
android:layout_alignParentRight="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/Button01"
android:text="Sign in" />
</RelativeLayout>
</TableRow>
Upvotes: 5