Josh Laird Josh Laird - 2 months ago 5
Android Question

Default AppCompatButton not writing in all caps

I have the support library added as a dependency

compile 'com.android.support:appcompat-v7:24.2.1'


My styles.xml looks like this:

<resources xmlns:android="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>


and my buttons themselves:

<android.support.v7.widget.AppCompatButton
android:layout_width="88dp"
android:layout_height="48dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="75dp"
android:layout_marginTop="82dp"
android:text="RETURN"
android:textSize="14sp"/>


The button currently looks like this: enter image description here

Also note how I have set the text to all caps but it's getting overwritten with normal lettering. Is the style being overridden somewhere?

I have tried adding:

style="@style/Widget.AppCompat.Button"
to the button but nothing has happened. Where am I going wrong?

Answer

Add android:textAllCaps="true" attribute to the Button

Comments