Android 文本视图中的文本未显示在多行中-它在一行中被截断

Android 文本视图中的文本未显示在多行中-它在一行中被截断,android,android-layout,textview,Android,Android Layout,Textview,下面是我的布局概要。我的ScrollView位于另一个LinearLayout中,因为我将在运行时向它添加更多视图 无论如何,问题是-文本视图中的文本总是被截断为一行,并且永远不会显示在多行中 有没有办法让它显示一个多行TextViw,而不必使用android:lines或android:maxLines设置任意数量的行 谢谢 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

下面是我的布局概要。我的ScrollView位于另一个LinearLayout中,因为我将在运行时向它添加更多视图

无论如何,问题是-文本视图中的文本总是被截断为一行,并且永远不会显示在多行中

有没有办法让它显示一个多行TextViw,而不必使用android:lines或android:maxLines设置任意数量的行

谢谢

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent" android:layout_height="fill_parent"
          android:orientation="vertical" android:background="@drawable/background"
          android:id="@+id/XyzLayout"
          android:paddingRight="10dp">

    <ScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="@drawable/background"
            android:fillViewport="true">

        <LinearLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content" android:orientation="vertical"
                  android:layout_marginBottom="0dip" android:layout_marginTop="1dip">

            <TextView android:id="@+id/textView1"
                  android:text="@string/String1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="10dip"
                  android:layout_marginTop="20dip"
                  android:layout_marginRight="10dip" android:textSize="18dip"
                  android:typeface="sans" android:textStyle="bold"
                  android:layout_marginBottom="4dip"
                  android:inputType="text|textMultiLine"/>

            <TextView android:id="@+id/textView2"
                  android:text="@string/String2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="10dip"
                  android:layout_marginTop="20dip"
                  android:layout_marginRight="10dip" android:textSize="16sp"
                  android:typeface="sans" android:textStyle="bold"
                  android:layout_marginBottom="4dip"
                  android:inputType="text|textMultiLine"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

默认情况下可能为false,但您是否尝试在TextView中添加此选项

 android:singleLine="false"

-serkan默认情况下可能为false,但您是否尝试在TextView中添加此选项

 android:singleLine="false"
-serkan

尝试删除设置android:inputType=text

只是有同样的问题。我有了android:multiLines=2,然后我尝试了android:lines=2,然后尝试添加android:singleLine=false,但我的EditText仍然只显示一行。我可以水平滚动到行的末尾。最终起作用的是删除设置android:inputType=text。这使我可以键入一个长行,然后换行到第二行。

尝试删除设置android:inputType=text


只是有同样的问题。我有了android:multiLines=2,然后我尝试了android:lines=2,然后尝试添加android:singleLine=false,但我的EditText仍然只显示一行。我可以水平滚动到行的末尾。最终起作用的是删除设置android:inputType=text。这使我可以输入一个长的行,这将绕到第二行。

我在使用CM72.3.7的i5800和仿真器时遇到了这个问题,并且在使用CM9 4.0.3的SGS-i9000上运行良好

问题是在清单上设置主题:

 <application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.DeviceDefault" >
我把android:theme=@android:style/theme.Holo放进去,如果设备没有它,textview就不允许多行

您可以使用holoeverywhere库将holo主题移植到所有设备


问候。

我在使用CM72.3.7的i5800和仿真器时遇到了这个问题,在使用CM9 4.0.3的SGS-i9000上运行良好

问题是在清单上设置主题:

 <application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.DeviceDefault" >
我把android:theme=@android:style/theme.Holo放进去,如果设备没有它,textview就不允许多行

您可以使用holoeverywhere库将holo主题移植到所有设备


问候。

要补充@KNU的回答

这里有一个很好的相关答案,表明您可以根据运行的Android版本使用不同的主题-只需创建一个版本化的样式文件夹


此处回答:

要添加到@KNU的回答中

这里有一个很好的相关答案,表明您可以根据运行的Android版本使用不同的主题-只需创建一个版本化的样式文件夹


在这里回答:

将输入类型设置为inputType=text | textMultiLine。这是为了解决我的问题

<TextView
    android:id="@+id/itemTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="text|textMultiLine"
    android:textSize="@dimen/text_size_12"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="Your Text Here"/>

将输入类型设置为inputType=text | textMultiLine。这是为了解决我的问题

<TextView
    android:id="@+id/itemTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="text|textMultiLine"
    android:textSize="@dimen/text_size_12"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="Your Text Here"/>

事实上,我想要的是相反的结果。我希望单线是假的。不管怎样,我会尝试添加这一点,看看是否有效。谢谢。不,那也不行。在我的其他布局中,我已经将文本视图包装得很好了。我只是想知道这一个有什么不同。对不起,我本想在那里键入false,但很遗憾听到它不起作用。让我再想想……谢谢。我的队友刚刚发现我们在清单中为活动设置了错误的主题,这导致了这个问题。移除后,它工作正常。谢谢你的回答。我只是好奇,你在文本视图中所做的更改不应该覆盖你在主题中所做的任何配置吗?我实际上想要的是相反的。我希望单线是假的。不管怎样,我会尝试添加这一点,看看是否有效。谢谢。不,那也不行。在我的其他布局中,我已经将文本视图包装得很好了。我只是想知道这一个有什么不同。对不起,我本想在那里键入false,但很遗憾听到它不起作用。让我再想想……谢谢。我的队友刚刚发现我们在清单中为活动设置了错误的主题,这导致了这个问题。移除后,它工作正常。谢谢你的回复。只是好奇,你在文本视图中所做的更改是否应该覆盖你在主题中所做的任何配置?