android - 如何使TableRow从右到左

标签 android right-to-left android-tablelayout tablerow

如何从右到左向 TableRow 添加 View ?默认模式是从左到右。我在 TableLayoutTableRow 中尝试了 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/

相关文章:

html - 括号错误地显示为从右到左的显示样式

c# - .NET 的正则表达式引擎如何处理 RTL+LTR 混合字符串?

java - 如何将 ScrollView 动态添加到动态表行

android - 表格布局调整。是否可以?

Android 开发人员 - 警报管理器与服务

java - 通过parse.com添加图片库

android - Fontfamily 不适用于 Android Lollipop

android - 任何支持 48 kHz 的声学回声消除 (AEC) 库?

css - 如何将 jqueryui 用于从右到左的语言

android - 按钮布局均匀填充屏幕大小