如何从右到左向 TableRow
添加 View ?默认模式是从左到右。我在 TableLayout
和 TableRow
中尝试了 android:gravity="right"
和 android:layout_gravity="right"
但没有用。
例如:
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layoutDirection="rtl"
android:stretchColumns="*" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:layoutDirection="rtl">
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text" />
</TableRow>
</TableLayout>
结果是左侧的 button1 和右侧的 textView1,但我需要反过来。
最佳答案
ViewCompat.setLayoutDirection(tableRow,ViewCompat.LAYOUT_DIRECTION_RTL);
关于android - 如何使TableRow从右到左,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23443248/