【发布时间】:2012-01-06 13:34:00
【问题描述】:
我正在编写一个简单的 Android 应用程序,它需要一些应该从右向左书写的文本。所以我使用了一个 TableRow 如下:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:id="@+id/ada"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="1"
android:text="Open..."
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/myview"
android:layout_marginRight="34dip"
android:layout_marginLeft="6dip"
android:layout_height="100dip"
android:layout_width="wrap_content"
android:layout_column="1"
android:text="Ctrl-O"
android:gravity="right"
/>
</TableRow>
</TableLayout>
在活动内部,我写道:
TextView myView=(TextView)findViewById(R.id.myview);
myView.setText("welcome 1 ");
效果很好,“欢迎 1”位于右侧(根据需要)。但是当文本长度增加时,TextView 无法正确显示文本,并且每行的末尾都超出了屏幕。这是一个截图,如果我将上面的代码更改如下:
myView.setText("welcome 1 welcome 2 welcome 3 welcome 4 welcome 5 welcome 6 welcome 7 welcome 8 welcome 9 welcome 10 ");
您的帮助将不胜感激。
【问题讨论】:
标签: android alignment tablerow