TextView 不会破坏文本

2023-12-04

我遇到了 textView 无法在 ICS 之前换行的问题。在 ICS 中(我相信蜂窝也能工作,但我还没有尝试过),textView 中的文本很好地打破了,但在姜饼和下面的文本中只是继续一行。任何想法如何解决这一问题?

我正在使用 viewpager,这是每个屏幕的布局。我使用自定义 textView 只是为了添加自定义字体,希望这不是问题。

pager_item.xml:`

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="20dp" >

    <com.ursus.absolution.startme.MyTextView
        android:id="@+id/message_textview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/quotes_background"
        android:gravity="center"
        android:textColor="#585858"
        android:textSize="25dp" />

    <com.ursus.absolution.startme.MyTextView
        android:id="@+id/author_textview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textColor="#585858"
        android:textSize="20dp" />

</LinearLayout>`

In ICS
_____________
|           |
|           |
| "This is  |
|  my cool  |
|   text"   |
|           |
|___________|

In gingerbread and below
_____________
|           |
|           |
| "This is my cool text"
|           |
|           |
|           |
|___________|

抱歉,我是新人,无法发布图片。先谢谢大家了,希望你们能得到。

///////更新///////////////


这个问题有多种形式的报道,here and here例如。许多问题报告了之前的工作布局被破坏了更新到 ICS/holo 主题时.

我能够轻松地重现它,这只是一行 xml 的问题:@android:style/Theme.Holo

绕过它的最简单方法是引入版本化值文件夹,让 Android 选择正确的一个。换句话说,你将有 2 个 styles.xml:

  • inside values-v11您应该放置您指定的文件夹(使用parent="@android:style/Theme.Holo")
  • 里面旧values您将放置“普通”文件夹,其中parent="android:Theme.Black.NoTitleBar".

您的清单应保持不变,Android 将根据其版本选择正确的 xml。该解决方案可能不是最优雅的,但至少你不会弄乱 android:maxlines、android:width 等

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TextView 不会破坏文本 的相关文章

随机推荐