Sat*_*lva 5 android textview android-layout android-tablelayout
首先,我进行了 Google 搜索并查看了StackOverFlow中与文本被截断相关的问题TextView。尽管它们提供了对某些事情的更好理解,但它们并没有帮助解决当前的问题。
这是我的问题。
我用来TableLayout显示带有两个文本字段的记录。每行有两个TextView单元格。对于所有单元格layout_width都设置为。wrap_content但是,即使文本以多行显示,多行文本中的每一行都会在末尾被切断。
例如
<?xml version="1.0" encoding="utf-8"?>
</TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content">
<TableRow>
<TextView
android:text="Notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/visitation_notes" />
<TextView
android:text="Need to visit again. Visit till the doctor understands the importance of the Test. The problem is, it is very difficult to get appointment for the visit. Still, we need to keep trying till the point reaches to him/her."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/visitation_notes_value"
android:textAlignment="viewStart"/>
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
产生了视图
备注:需要再次访问。拜访直到医生了解测试的重要性。问题是,预约参观非常困难。尽管如此,我们还是需要继续努力,直到达到他/她的目标。
粗体文字被截断。
如果我用LinearLayout代替TableLayout,效果很好。但是,问题是我不能让每行的第二列从同一位置开始(没有硬编码)。
请帮助我如何确保TextView内容不会被切断。
这是上面给出的示例所生成的视图的屏幕截图。
尝试此代码并适合所有设备
<?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:background="@color/bgcolor"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="10dip" >
<LinearLayout
android:id="@+id/llAvailableBookings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="25dip"
android:gravity="center"
android:textSize="24.5sp"
android:visibility="gone" />
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:stretchColumns="*" >
<TableRow>
<TextView
android:id="@+id/visitation_notes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Notes" />
<TextView
android:id="@+id/visitation_notes_value"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="Need to visit again. Visit till the doctor understands the importance of the Test. The problem is, it is very difficult to get appointment for the visit. Still, we need to keep trying till the point reaches to him/her."
android:textAlignment="viewStart" />
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3153 次 |
| 最近记录: |