I'm starting the Android app development and I'm trying to code my first app in Android, however I am encountering a problem with Strings in TextView. The problem is that I am trying to use some special characters for my app (like "µ" sign) and "/" but the xml does not recognize those signs and replace them with "DEMO CASE" either in preview or during runtime on a real device.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ti_layout_aceta"
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
app:endIconMode="clear_text"
app:layout_constraintEnd_toStartOf="@id/gl_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cv_a_header">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_unit1_aceta"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/hint"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>
I tried those codes ⁄ ⁄ for "/" and µ µ for "µ" but still have the same problem.
Some special characters aren't properly supported in XML texts. You can wrap them in a CDATA
block:
<string name="hint"><![CDATA[µ]]></string>
There is an easy was to do this in Android Studio. Put your cursor inside the text, press Alt+Enter
and select this option: