I get this error message:
> 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.
whenever I use these strings (below) in values->strings in Android Studio. Please take a look at them what should I add or remove;
<!--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>
CodePudding user response:
The strings.xml resource file does not handle fonts, it should contain only strings and nothing more. Therefore you should define them for example as next:
<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>
Then if the text is concatenated you can manage the font sizes either by composing them in code with a Spannable by defining multiple font sizes, or assigning each text to a different TextView each with your required font TextSize
Tip: in strings.xml, when a text contains single quote characters ( ' ), if you wrap the full text between double quotes then there is no necessity to scape each single quote.
CodePudding user response:
You cannot use html like that in the strings.xml. You should either use CDATA[] like below:
<string name="string_html"><![CDATA[<b>Html text</b>]]></string>
or otherwise like below example:
<string name="string_html"><b>Html text<br><font color=\"#fe2e68\">text example</font></b></string>