TextView won't break text

后端 未结 2 977
别跟我提以往
别跟我提以往 2021-01-07 05:52

I am having trouble with textView not breaking line before ICS. In ICS (i belive honeycomb works as well but i havent tried it tho) the text inside textView breaks nicely bu

相关标签:
2条回答
  • 2021-01-07 06:17

    This issue is reported in various forms, here and here for example. Many of the issues reports a previous working layout that gets broken when updating to ICS/holo theme.

    I was able to reproduce it easily, it's a matter of a line of xml: @android:style/Theme.Holo

    The easiest way to go around it is to introduce a versioned values folder, to let Android pick the right one. In other words You'll have 2 styles.xml:

    • inside values-v11 folder you should put the one you specified (with parent="@android:style/Theme.Holo")
    • inside old values folder you'll put the 'plain' one, with parent="android:Theme.Black.NoTitleBar".

    Your manifest should remain unchanged, and Android will pick the right xml based on its version. The solution may not be the most elegant, but at least you won't mess with android:maxlines, android:width and so on

    0 讨论(0)
  • 2021-01-07 06:25

    In addition to Shine answer I had to set corresponding parameters to the TextView:

                    android:ellipsize="none"
                    android:maxLines="20"
                    android:scrollHorizontally="false"
                    android:singleLine="false" 
    

    Example:

               <TextView                  
                    android:textColor="@color/white"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="none"
                    android:maxLines="20"
                    android:scrollHorizontally="false"
                    android:singleLine="false"
                    android:text="@string/my_text" />
    
    0 讨论(0)
提交回复
热议问题