TextView中的部分单词不在屏幕之外!

时间:2011-05-02 21:10:15

标签: android

嘿,我有一个问题,TextView中的部分文本都在屏幕之外,看看图片: enter image description here

我在红色方块中标记了问题.. xml:

<?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:layout_gravity="right"
  android:background="@drawable/list"
  android:padding="15px">

  <ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="right">

<TextView 
android:id="@+id/TfseerTextView"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:textSize="17px"
android:textColor="#000"
      ></TextView>
        </LinearLayout>
        </ScrollView>

</LinearLayout>

可以修复吗?有什么工作吗?感谢。

1 个答案:

答案 0 :(得分:0)

你应该使用17sp而不是17px作为textSize。 sp代表Scaled Pixel,它会使您的应用在各种屏幕尺寸和密度不同的设备上显得更好/更一致。

至于你遇到的问题。如果将TextViews layout_width属性设置为某个值,这会有什么不同吗? android:layout_width="200dip"在我看来,你的TextView认为它有更多的空间可供使用,然后它实际上(可能与你背景的灰盒子类型相关,但这是一个纯粹的猜测)如果你设置它到某个特定的值,它开始正确地将文本包装在下一行。然后你只需要尝试几个不同的宽度,并找出你可以做多大,以保持一切看起来应该如此。