Ich versuche, meine Stile einzurichten, um alle Schaltflächen eine bestimmte Farbkombination, insbesondere blau mit weißem Text. Hier ist meine Haupt styles.xml:Android-Standard-Button-Styling funktioniert nicht
<resources>
<style name="CustomTheme" parent="MaterialDrawerTheme.Light.DarkToolbar">
<!-- various items -->
<item name="android:buttonStyle">@style/ButtonStyle</item>
</style>
<!-- a couple of other styles -->
<style name="ButtonStyle" parent="android:style/Widget.Button">
<item name="android:textSize">19sp</item>
<item name="android:textColor">@color/primaryTextContrast</item>
<item name="android:background">@color/primary</item>
</style>
</resources>
Und im Manifest:
<application
android:name=".CustomApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
android:theme="@style/CustomTheme">
color/primary
ist dunkelblau, und color/primaryTextContrast
ist weiß. Auf Lollipop sieht die Schaltfläche perfekt aus. Auf einem 4.1 Gerät ist es hellgrau mit schwarzem Text. Jede Ressource, die ich dafür gefunden habe, sieht genau so aus, wie ich es mache. Ich weiß nicht, was ich hier vermisse.
Ich habe ein ähnliches Problem mit der Steuerung der Textgröße in der Basis-Stil-Definition.
Update: hier sind die Farben.
<resources>
<color name="primary">#3F51B5</color>
<color name="dark">#303F9F</color>
<color name="accent">#FFCA28</color>
<color name="background">@android:color/white</color>
<!-- Color for text displayed on top of the primary or dark color -->
<color name="primaryTextContrast">@android:color/white</color>
<!-- Color for text displayed on the background color (which I think will always be white) -->
<color name="basicText">@color/primary</color>
<!-- Color for text displayed on the accent color -->
<color name="accentText">#303F9F</color>
</resources>
Hier v19/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FullscreenTheme" parent="MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus">
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
hier v21:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="CustomTheme">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
Ich glaube nicht, entweder von diesen ist, was richtig auf 5.1 funktioniert bewegt.
Ihr Code funktioniert perfekt in meiner Galaxie s3 mini (Android 4.1), sind Sie sicher, dass Sie nicht über zwei Versionen von styles.xml, und das mit diesem Code ist> v16? – Ruocco
Ich habe zwei Versionen, aber dies ist die in main/res/values. – nasch
@Jones Ich habe meine zusätzlichen Style-Dateien hinzugefügt. – nasch