把中间一个空间透明度设为0, android:layout_weight=”1.0”
<LinearLayout
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:text="My Events"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:alpha="0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<ImageView
android:src="@drawable/draw_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
https://blog.csdn.net/xiyangyang8110/article/details/54602303
android 线性布局居右
android:gravity指的是控件的文本相对控件的位置
layout_gravity指的是控件相对窗口的位置
在使用 android:layout_gravity时一定要注意三点:
1. 是在linearlayout布局方式中
2.android.orientation="vertical"
3.窗口的布局方式的layout_width=”fill_parent"
代码如下:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:text="one"
android:layout_gravity="right"/>
</LinearLayout>
https://www.cnblogs.com/lengyue/archive/2013/01/08/2851311.html