I'm having an issue using Material button on a recycler view. When i set iconGravity = ICON_GRAVITY_TEXT_START looks like it's property not work sometimes when view is recycled.
I notice that when all rows have an icon, this problem not occurs, but when one row not show an icon i got this case.
The xml i'm using
<com.google.android.material.button.MaterialButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:background="@android:color/holo_red_dark"
android:minWidth="160dp"
app:backgroundTint="@null"
android:gravity="center"
app:iconGravity="textStart"
app:iconPadding="8dp"
android:textAlignment="center" />
And the code
fun bind(data: ButtonVO) {
button.apply {
text = data.text
if(data.showIcon)
setIconResource(R.drawable.ic_play_arrow)
else
setIconResource(0)
}
}
The result when view is recycled
Someone have any clue?