简体   繁体   English

无法在Android 4.3上换行TextView文本

[英]TextView text not wrapping on Android 4.3

I have a RelativeLayout containing a Textview. 我有一个包含Textview的RelativeLayout。 I want the TextView text to wrap on multiple lines. 我希望TextView文本换行。

It works fine on Android 4.1 and 4.2 (haven't tried earlier versions). 它在Android 4.1和4.2上运行良好(尚未尝试使用较早版本)。 However, on Android 4.3 the text doesnt wrap and is cut (see screenshots below). 但是,在Android 4.3上,文本不会自动换行并被剪切(请参见下面的屏幕截图)。

Layout.xml: Layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/feed_item"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/touchable_background_msf"
    android:padding="@dimen/feed_item_padding" >

    <com.binarymango.msfnews.images.RecyclingImageView
        android:id="@+id/feed_item_icon"
        android:layout_width="@dimen/feed_thumb_width"
        android:layout_height="@dimen/feed_thumb_height"
        android:contentDescription="Description" />

    <TextView
        android:id="@+id/feed_item_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/feed_item_icon"
        android:layout_alignLeft="@+id/feed_item_icon"
        android:layout_alignRight="@+id/feed_item_icon"
        android:background="@color/text_background_msf"
        android:ellipsize="end"
        android:maxLines="3"
        android:minLines="2"
        android:padding="@dimen/feed_item_text_padding"
        android:text="Description"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@color/text_msf" />

</RelativeLayout>

Result on Android 4.2, the text is correctly wrapped in 3 lines: 在Android 4.2上显示结果,该文本正确地分为3行: 在此处输入图片说明

But on Android 4.3, the text is just cut: 但是在Android 4.3上,文本被剪切: 在此处输入图片说明

I've been trying to play with several attributes as mentioned elsewhere in StackOverflow in vain: 我一直在尝试徒劳地使用StackOverflow中其他地方提到的几个属性:

android:singleLine="false"
android:scrollHorizontally="false"
android:inputType="textMultiLine"
android:width="0dip"

Also, I suspect it may have to do with the theme. 另外,我怀疑这可能与主题有关。 My app uses Theme.AppCompat.Light 我的应用程序使用Theme.AppCompat.Light

例如,您可以使用android:line="3"与第一张图片具有相同的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM