0

Ich versuchte es in styles.xml mit Zugabe etwa so:Wie man Knopftext pre-Lollipop groß schreibt?

<!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Main theme colors --> 
     <!-- your app branding color for the app bar --> 
     <item name="colorPrimary">@color/primary</item> 
     <!-- darker variant for the status bar and contextual app bars --> 
     <item name="colorPrimaryDark">@color/primary_dark</item> 
     <!-- theme UI controls like checkboxes and text fields --> 
     <item name="colorAccent">@color/accent</item> 

     <!-- buttons will not have shadows --> 
     <item name="android:buttonStyle">@style/Widget.AppCompat.Button.Borderless</item> 
     <item name="android:textAppearanceButton">@style/DefaultButtonTextStyle</item> 

     <item name="android:colorBackground">@android:color/white</item> 

    </style> 

<!--The button text style to be used throughout the app--> 
    <style name="DefaultButtonTextStyle" parent="@style/Base.TextAppearance.AppCompat.Button"> 
     <!-- Ensure that the buttons are all caps even pre Lollipop--> 
     <item name="android:textAllCaps">true</item> 
     <item name="textAllCaps">true</item> 
    </style> 

Antwort

1

Sie müssen nur einen benutzerdefinierten Stil für Ihre Schaltfläche, um Ihre Schaltfläche

<style name="CustomButton"> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:layout_width">wrap_content</item> 
    <item name="android:layout_centerVertical">true</item> 
    <item name="android:textAllCaps">true</item> 
</style> 

Dann legen Sie es schaffen wie:

<Button 
    android:id="@+id/total_bill" 
    style="@style/CustomButton" /> 

Oder Sie können so etwas wie:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="buttonStyle">@style/MyButton</item> 
    </style> 

    <style name="MyButton" parent="Widget.AppCompat.Button"> 
     <item name="android:textAllCaps">true</item> 
    </style> 

Die zweite Methode wird es für alle Schaltfläche über die Anwendung ändern.Eine andere Möglichkeit ist, die Schaltfläche zu erweitern und erstellen Sie eine benutzerdefinierte Schaltfläche, wo Textcaps auf True festgelegt ist und diese Schaltfläche anstelle der Standard verwenden.

+0

Ich nehme an false sollte sein true Sree

+0

Das hat funktioniert! Ich machte das früher, aber statt @ style/MyButton machte ich @ style/MyButton. Wann Präfix "android:" und wann nicht? – Sree

+0

Für Android spezifische Namen verwenden Sie Android: .Für benutzerdefinierte Theme Name gibt es keine Notwendigkeit, Android :. –