我用了 android:layout_gravity="right"没什么效果,不知道怎么弄啊。。。
<?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:layout_width="50px"
android:layout_height="50px"
android:text="002"
android:background="#ff00ff"
android:gravity="center"
android:layout_gravity="right"/>
</LinearLayout>
layout_gravity和gravity都没有效果,用layout_weight来进行设置
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="左边"
android:layout_weight="1"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>
通过layout_weight来设置,把左边的元素设置小一点然后把imgview挤到右边
将android:layout_gravity="right"属性设置给LinearLayout