2

我在使用textView之前沒有斷開ICS之前的線路。在ICS(我相信蜂窩工作,但我還沒有嘗試過壽)textView內的文本很好地打破,但在薑餅和文本下面只是繼續在一行。任何想法如何解決這一問題?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" 
|   | 
|   | 
|   | 
|___________| 

對不起即時通訊新我不能張貼圖片。在此先感謝,希望你們得到它。

/////// UPDATE ///////////////

好球員,這很有趣。我嘗試了所有的建議,但是既沒有工作,所以我開始了一個新的空白項目,只是把一個textview與真正的長字符串佈局,它包裹得很好。

所以,我不知道這是怎麼可能的,但它的風格做這個操作欄的自定義主題,當我在清單中註釋它工作得很好,但是系統全息主題似乎這樣做

AndroidManifest.xml中

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.ursus.absolution.startme" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="15" /> 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> 

<application 
    android:icon="@drawable/iconn" 
    android:label="@string/app_name" 
    android:theme="@style/Theme.myStyle" > 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/title_activity_main" > 
    </activity> 
    <activity 
     android:name=".SplashScreenActivity" 
     android:label="@string/title_activity_main" 
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

styles.xml

<resources> 

<style name="Theme.myStyle" parent="@android:style/Theme.Holo"> 
    <item name="android:actionBarStyle">@style/mycoolstyle_transparent_ActionBar</item> 
</style> 

<style name="mycoolstyle_transparent_ActionBar" parent="@android:style/Widget.Holo.ActionBar"> 
    <item name="android:background">@drawable/transparent_actionbar</item> 
</style> 

...所以當我添加機器人:在清單主題= 「@風格/ Theme.myStyle」 的textviews胡作非爲然而,當我添加機器人:主題=「@安卓風格/主題。全息「而不是,因爲我通常會強制全息主題,它missbehave以及

怪異。

+0

可能重複(http://stackoverflow.com/questions/2197744/android-textview-text-not-getting-wrapped) – wsanville 2012-07-20 16:23:08

+0

嘗試向你的TextView添加'android:singleLine =「false','false'應該是默認值但也許在你的應用中覆蓋它。 – Dalmas 2012-07-20 16:26:58

+0

正常的TextView會自動換行,所以我認爲問題出在您的自定義TextView上。如果您只想更改字體,請使用'android:typeface =「」',如[在此討論](http://stackoverflow.com/q/2888508/1267661)。如果您仍然需要幫助,請發佈您的MyTextView類,以便我們看到發生了什麼。 – Sam 2012-07-20 16:27:54

回答

8

例如,以各種形式報告此問題,herehere。許多問題報告了以前的工作佈局,當更新到ICS/holo主題時,會打破

我能夠很容易地複製它,這是一個行的xml的問題:@android:style/Theme.Holo

最簡單的方法去解決它是推出一個版本值夾,讓Android的選擇是正確的。換句話說,你將有2 styles.xml:

  • values-v11文件夾內,你應該把你指定的一個(與parent="@android:style/Theme.Holo"
  • 內老values文件夾,你會放「純」之一, parent="android:Theme.Black.NoTitleBar"

您的清單應該保持不變,Android會根據其版本選擇正確的xml。該解決方案可能不是最優雅,但至少你不會與Android亂:的maxlines,安卓寬度等

+0

OMG非常感謝你的支持!我有2個相同的應用程序,1免費廣告,1付費。 TextView在免費版中正確顯示,但不是付費版。原來,我在付款人的清單中有'android:theme =「@ android:style/Theme.Holo」',但不是免費的...一旦我刪除了它,它就起作用了! – Randy 2012-12-31 15:47:31

0

除了閃耀的答案,我不得不相關參數的設置,以TextView的:

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

實施例:

  <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" /> 
[Android的TextView的文本不獲取包裹]的