我收到此錯誤訊息:
> Task :app:mergeDebugResources
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:51:4: Failed to flatten XML for resource 'Turn_Your_Ideas_into_Product' with error: Attempting to flatten xml with unfinished spans.
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:51:4: string/Turn_Your_Ideas_into_Product does not contain a valid string resource.
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:65:4: Failed to flatten XML for resource 'Write_a_Short_Book' with error: Attempting to flatten xml with unfinished spans.
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:65:4: string/Write_a_Short_Book does not contain a valid string resource.
每當我在 Android Studio 的 values->strings 中使用這些字串(如下)時。請看看他們我應該添加或洗掉什么;
<!--Record Your Conversations-->
<string name="Record_Your_Conversations">
<font size="17">Record Your Conversations</font>\n
<font size="13">Is there a subject that you\'re exceptional knowledgeable about? Or even a subject that you\'re really interested in diving into a little deeper? Are you a good listener?…</font>
</string>
<!--Write a Short Book-->
<string name="Write_a_Short_Book">
<font size="17">Write a Short Book</font>\n
<font size="13">Writing a book is not easy, but we\'ll assist you, and this is especially good avenue to take if you're not interested in audio, video, or physical products…</font>
</string>
編輯:
我還有其他類似的字串,比如這個:
<!--Teach People What You Know-->
<string name="Teach_People_What_You_Know">
<font size="17">Teach People What You Know</font>\n
<font size="13">I bet you know things. Things that other people don\'t know. Music, sales, yoga etc. These are things people are constantly learning…</font>
</string>
它對他們有用,我不知道其他 2 個字串有什么問題..
謝謝你的幫助..
uj5u.com熱心網友回復:
在strings.xml中的資源檔案不處理字體,它應該只包含字串,僅此而已。因此,您應該將它們定義為例如下一個:
<string name="record_conversation_title">Record Your Conversations</string>
<string name="record_conversation_message">"Is there a subject that you're exceptional knowledgeable about? Or even a subject that you're really interested in diving into a little deeper? Are you a good listener?…"</string>
然后,如果文本被連接,您可以通過定義多個字體大小將它們組合在帶有Spannable的代碼中來管理字體大小,或者將每個文本分配給不同的 TextView,每個文本都具有所需的字體TextSize
提示:在 strings.xml 中,當文本包含單引號字符 ( ' ) 時,如果將全文括在雙引號之間,則無需轉義每個單引號。
uj5u.com熱心網友回復:
你不能在strings.xml 中使用這樣的html。您應該使用 CDATA[] 如下所示:
<string name="string_html"><![CDATA[<b>Html text</b>]]></string>
或者像下面的例子一樣:
<string name="string_html"><b>Html text<br><font color=\"#fe2e68\">text example</font></b></string>
uj5u.com熱心網友回復:
這是你的問題,你有一個未轉義的參考Write_a_Short_Book:
如果你不感興趣,就拿
您沒有發布Turn_Your_Ideas_into_Product(錯誤日志中的另一個),但這可能是相同的問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/383167.html
