Erstellt benutzerdefinierten Stil für Schaltfläche, wenn Sie den Stil für Schaltfläche anwenden, ist es teilweise. Hier ist das Stil-Code-Snippet.Angepasster Button-Stil wird teilweise angewendet
Manifest.xml
<application android:theme="@style:AppTheme">
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:buttonStyle">@style/back_button_style</item>
<item name="buttonStyle">@style/back_button_style</item>
</style>
<style name="back_button_style" parent="Widget.AppCompat.Button">
<item name="background">@drawable/back_button_shape</item>
<item name="android:layout_height">40dp</item>
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textAlignment">center</item>
<item name="android:textAllCaps">true</item>
<item name="android:layout_marginStart">72dp</item>
<item name="android:layout_marginEnd">72dp</item>
<item name="android:fontFamily">sans-serif</item> //sans-serif nothing but robot regular
</style>
layout.xml
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.501"
android:layout_marginBottom="8dp" />
Nach applyin g der Stil nur die Textfarbe ändert sich zu Weiß, da ich die Textfarbe als weiß in der Art gegeben habe, aber andere Anmeldeinformationen nicht Hintergrund angewendet werden, vor dem Anwenden der Knopftextfarbe war Schwarzes. Also ich verstehe nicht, warum es teilweise den Stil anwendet.
ich so auch versucht, aber es funktioniert nicht
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.501"
android:layout_marginBottom="8dp"
android:theme="@style/back_button_style/>
ich nicht bekommen, was und wo der Fehler im Code ist.
Mögliche Duplikate von [Wie benutzerdefinierte Schaltfläche in Android mit XML-Formatvorlagen erstellen] (https://stackoverflow.com/questions/18507351/how-to-create-custom-button-in-android-using-xml-styles) – akhilesh0707
versuche 'style =" @ style/back_button_style "' anstelle von 'android: theme =" @ style/back_button_style "' – Joshua
'android: theme =" @ style/AppTheme "' –