I'm making my first app in android studio. It's going well so far, but I've come across this stumbling block:
I have absolutely no idea how to edit already defined colours.
Here's some screenshots from two of the activities:
Inside the layout .xml code i have coloured everything like this:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutReset"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/resetNutsButton"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_margin="30dp"
android:background="@drawable/round_corners"
android:backgroundTint="@color/Accent1" //Accent colour
android:fontFamily="@font/lemonmilkregular"
android:text="Reset nuts"
android:textAlignment="center"
android:textColor="@color/Back1" //grey
android:textSize="25sp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Everything in the project has been coloured using the colors.xml file and, as you can see from the 2nd picture, I would like to add the option to choose an accent colour to be used everywhere that is currently red.
I've looked through many questions and I can see that editing any of the resource files during runtime is not possible, so I was wondering what the best way is to go about this.
As I said, this is my first app, so I may just be missing something simple.
Any input is appreciated, and if you need any more details please tell me.
question from:
https://stackoverflow.com/questions/65907282/how-to-change-global-accent-colour-through-code 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…