I have a 10×10 Hex Game board which consists of hexagonal buttons. I am trying to change the color of the hexagons when user clicks on them. I tried lots of things but my buttons are always purple.
I tried to use the blue,black,red hexagons but weirdly every single one is purple when I use them as button backgrounds.
XML for one button(I have 100 of these):
<Button
android:id="@+id/button00"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/hexagon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.300" />
I tried the following functions
buttons[finalI][finalJ].setBackgroundColor(Color.parseColor("#666bff")); //hexagons becomes squares, but still purple.
buttons[finalI][finalJ].setBackgroundResource(R.drawable.hexagonblue); //still purple
How can I change the colors of buttons and why all the buttons are purple even though I upload different colors of png hexagons?
Source: Android Studio Questions