Reputation: 43
I have this XML tag:
<Button
android:id="@+id/next"
android:layout_width="305dp"
android:layout_height="64dp"
android:background="@color/colorTheme"
style="@style/ButtonStyle"
android:text="Next"
app:layout_constraintBottom_toTopOf="@+id/imageViewFooterGetStarted"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.968" />
For some reason the background color of my button doesn't change. I've tried using only style.xml:
<style name="ButtonStyle" parent="android:Widget.Button">
<item name="android:background">@drawable/btn_get_started</item>
<item name="android:textColor">@color/colorTheme</item>
</style>
And still has the default purple color. android:background
doesn't have any effect either.
What could be causing the background color not to change?
Edit: I found the solution. Turns out android:background
changes the color but only if <androidx.appcompat.widget.AppCompatButton>
tag is used instead of <button>
tag
Upvotes: 1
Views: 1856
Reputation: 1
screenshot Replace <Button... /> with <androidx.appcompat.widget.AppCompatButton... /> in code of Activity_main.xml
Upvotes: 0
Reputation: 113
Try with AppCompatButtom instead of Button
Replace your Button With AppCompatButtom
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/next"
android:layout_width="305dp"
android:layout_height="64dp"
android:background="@color/colorTheme"
style="@style/ButtonStyle"
android:text="Next"
app:layout_constraintBottom_toTopOf="@+id/imageViewFooterGetStarted"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.968" />
Hope its work !!
Upvotes: 3