I'm trying to set a TextView to use monospaced font. A seemingly trivial task (and I've been developing for Android since 2010) but alas I must be missing something.
This keeps the default font, definitely not monospaced:
mOutputText.typeface = Typeface.MONOSPACE
...
private lateinit var mOutputText: TextView
Tried this too:
<TextView
android:id="@+id/test_log"
android:typeface="monospace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff0f0f0"
android:padding="16dp"
android:textSize="16sp"/>
Same thing, the text view retains the default - non-monospaced - font.
I have these in my dependencies:
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
Am I perhaps seeing some strange artifact of using Google's Material library?
How do I set a TextView's font to monospaced in 2023?