Here is what the button looks like after changing the color
Here is what it looks like with "show layout bounds" on
I have an "add note" button which shows a dialog for the user to enter a note.
I want to change the color of the button if a note is saved.
I've tried this:
btnNote.setBackgroundColor(view.getContext().getResources().getColor(R.color.NN));
and this:
btnNote.getBackground().setColorFilter(ContextCompat.getColor(view.getContext(), R.color.NN), PorterDuff.Mode.MULTIPLY);
But in both cases the button also becomes slightly bigger.
How can I change only the color of the button?
this is my button from my layout file:
<Button
android:id="@+id/btnNote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Add note"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btnDelete"
app:layout_constraintTop_toTopOf="parent" />