Issue
I am trying to change the background color and text color of a material button-through style. However, I see no change in IDE and as well as on phone. Here is a screenshot of the issue.
The button next to cancel misbehaves, after checking in tons of attributes I fail to change background color.
Here is my XML:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_login_skip"
style="@style/myMaterialButton.Unboxed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn_login_login" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_login_login"
style="@style/myMaterialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pay_deail_submit_btn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Here is some style info:
<style name="myMaterialButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="android:textColor">@color/colorPrimary</item>
<item name="strokeWidth">2dp</item>
<item name="android:background">@color/colorPrimaryDark</item>
</style>
Here are colors:
<color name="colorPrimary">@color/silver</color>
<color name="colorPrimaryDark">#2A2E43</color>
Solution
By Material Official Source you should use app:backgroundTint
in your style
meanwhile for checking "Widget.MaterialComponents.Button.OutlinedButton" styles you should check buttons on Device or Emulator, sometimes buttons with this style dosent show good in IDE
Answered By - Mreza Nemati
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.