如何右对齐部件的水平线性布局的Android? [英] how to right align widget in horizontal linear layout android?
本文介绍了如何右对齐部件的水平线性布局的Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是在$ C $词现在用的,它是不工作:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=横向>
< TextView的Android版本:文本=TextView的机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:重力=权与GT;
< / TextView的>
< / LinearLayout中>
解决方案
试着要见右图元素之前添加水平的LinearLayout内空查看,如:
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT>
<查看
机器人:layout_width =0dp
机器人:layout_height =0dp
机器人:layout_weight =1
/>
<按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT/>
< / LinearLayout中>
This is the code i am using and it is not working:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right">
</TextView>
</LinearLayout>
解决方案
Try to add empty View inside horizontal LinearLayout before element that you want to see right, e.g.:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
这篇关于如何右对齐部件的水平线性布局的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文