我仍然没有找到如何在 XML 中做到这一点的解决方案 我希望我的 textview 向左对齐,而我的 imageview 向右对齐,代码如下:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_height="wrap_content"
android:text="Vibration"
android:layout_width="wrap_content" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:src="@drawable/ic_launcher" />
</TableRow>
</TableLayout>
有什么办法吗?
最佳答案
尝试将您的 TableRow
更改为以下内容:
<TableRow
android:id="@+id/tr1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Vibration"
android:gravity="left" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:gravity="right"
android:src="@drawable/ic_launcher" />
</TableRow>
关于android - 在 TableLayout 中右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12185670/