I am using the following material button:
<android.support.design.button.MaterialButton android:id="@+id/bFavourite" style="@style/Widget.MaterialComponents.Button.UnelevatedButton.Icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:insetTop="0dp" android:insetBottom="0dp" android:textAllCaps="false" android:textSize="20sp" app:backgroundTint="@color/main_dark_blue" app:backgroundTintMode="src_over" app:cornerRadius="0dp" app:icon="@drawable/heart_filled" app:iconGravity="textStart" app:iconPadding="0dp" />
heart_filled
is a png of a red heart. However the icon is showing without any color (i.e., a white heart). Why is the actual color of the image not showing? Thank you
Goto your layout/activity_filename. xml file and add this android:enabled="false" to your button widget.
Add icons to the start, center, or end of this button using the app:icon , app:iconPadding , app:iconTint , app:iconTintMode and app:iconGravity attributes. If a start-aligned icon is added to this button, please use a style like one of the ". Icon" styles specified in the default MaterialButton styles.
Material Buttons are slightly different to traditional Android buttons in that they do not include additional insets (4dp on the left/right) and have more letter-spacing, different default colors and other attributes that improve legibility and affordance amongst other components.
Maybe you are looking for this set iconTint
to null
<com.google.android.material.button.MaterialButton android:id="@+id/btnGoogle" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="end" android:layout_marginStart="@dimen/_2sdp" android:layout_weight="1" app:icon="@drawable/ic_google" app:iconGravity="textStart" app:iconTint="@null" android:elevation="@dimen/_10sdp" android:text="@string/string_google" android:textAllCaps="false" app:rippleColor="@color/colorBlueShade1" app:cornerRadius="@dimen/_20sdp" app:backgroundTint="@color/colorWhite" android:textColor="@color/colorPrimary" />
Achieved output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With