我正在这样做
<com.google.android.material.button.MaterialButton
android:id="@+id/btnProceed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Proceed to enter Gender"
style="@style/bottomBtnStyle"
app:icon="@drawable/ic_right_arrow"
app:iconGravity="textStart"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"/>
但是图标显示在文本的左侧,图标重力对图标位置没有影响。
在普通按钮中,我们曾经使用 drawableRight 实现相同的效果,但这里没有找到方法。
最佳答案
app:icon="@drawable/ic_right_arrow"
如果您需要在左侧显示,那很好。为了显示正确,您需要添加
app:iconGravity="end"
也。并确保您使用正确的按钮样式。这意味着bottomBtnStyle的父级必须是
Widget.MaterialComponents.Button
关于android - 如何在 MaterialButton 中的文本右侧添加可绘制对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56970678/