在水平方向的LinearLayout右对齐按钮 [英] Right Align button in horizontal LinearLayout
本文介绍了在水平方向的LinearLayout右对齐按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只是一个快速的愚蠢的问题。如果你看一下附带的图像。我需要我的按钮进行右对齐,但由于某种原因,它不工作重心:正确......
Just a quick stupid question. If you look at the attached image. I need my button to be right aligned but for some reason it's not working with 'gravity:right'...
下面是我的$ C $下的布局:
Here's my code for that layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="35dp">
<TextView
android:id="@+id/lblExpenseCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:textColor="#404040"
android:layout_marginLeft="10dp"
android:textSize="20sp"
android:layout_marginTop="9dp" />
<Button
android:id="@+id/btnAddExpense"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:background="@drawable/stitch_button"
android:layout_marginLeft="10dp"
android:text="@string/add"
android:layout_gravity="right"
android:layout_marginRight="15dp" />
</LinearLayout>
为什么没有工作?感谢球员...
Why is no working?! Thanks guys...
推荐答案
使用以下code为
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/lblExpenseCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="9dp"
android:text="@string/cancel"
android:textColor="#404040"
android:textSize="20sp" />
<Button
android:id="@+id/btnAddExpense"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="15dp"
android:background="@drawable/stitch_button"
android:text="@string/add" />
</RelativeLayout>
这篇关于在水平方向的LinearLayout右对齐按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文