J'essaie de créer un style global où mes boutons ont un arrière-plan gris foncé avec du texte blanc. La couleur du texte est bien. Je suis capable de le changer mais pour une raison quelconque, la couleur d'arrière-plan des boutons ne changera pas. Qu'est-ce que je fais mal.Pourquoi l'arrière-plan de mes boutons ne change pas
Voici mes couleurs xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#bf360c</color>
<color name="colorPrimaryLight">#f9683a</color>
<color name="colorPrimaryDark">#870000</color>
<color name="colorPrimaryText">#000000</color>
<color name="colorAccent">#a4a4a4</color>
<color name="colorWindowBackground">#fafafa</color>
<color name="RED">#ff0000</color>
<color name="BLUE">#000fff</color>
<color name="GREEN">#00FF00</color>
<color name="YELLOW">#FFEB3B</color>
<color name="DARK_GREY">#494949</color>
</resources>
Voici mon style xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">@color/colorPrimaryText</item>
<item name="android:textColorSecondary">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorWindowBackground</item>
<item name="android:buttonStyle">@style/buttonColor</item>
</style>
<style name="buttonColor" parent="android:style/Widget.Button">
<item name="android:textColor">@color/colorWindowBackground</item>
<item name="android:colorBackground">@color/DARK_GREY</item>
</style>
</resources>
Et pourquoi mon bouton de sortie rétrécir tout d'un coup?
Maintenant j'ai ceci mais le bouton de sortie a rétréci ??????
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
tools:context="com.checkinsystems.ez_score.MainActivity">
<Button
android:id="@+id/match_button"
android:layout_width="0dp"
android:layout_height="65dp"
android:onClick="goToMatchScreen"
android:text="@string/match_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<Button
android:id="@+id/competitors_button"
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_marginTop="15dp"
android:onClick="goToCompetitorsScreen"
android:text="@string/competitors_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/match_button"/>
<Button
android:id="@+id/scores_button"
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_marginTop="15dp"
android:onClick="goToScoresScreen"
android:text="@string/scores_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/competitors_button"/>
<Button
android:id="@+id/reports_button"
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_marginTop="15dp"
android:onClick="goToReportsActivity"
android:text="@string/reports_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scores_button"/>
<Button
android:id="@+id/exit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/exit_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
</android.support.constraint.ConstraintLayout>
wow c'était simple et cela a fonctionné. On pourrait penser que colorBackground, étant un attribut android aurait été la réponse. Aussi, je vais poster la nouvelle interface. Pourquoi changer la couleur changerait la taille du bouton? n'a aucun sens –
@ HelpMeI'mStupid Vous devriez mettre le xml du bouton afin que nous puissions voir ce qui se passe :) – joao86
fait. Une idée? C'est un comportement étrange. –