我想将图标放在 materialButton 的顶部,如下所示:
但是我在 MaterialButton 中找不到任何属性来设置应用程序的重力:图标到顶部。 我只能将它设置为开始或结束。 有没有什么方法可以设置创建一个类似的按钮,而无需将 Vertical LinearLayout 与 ImageView 和 TextView 一起使用?
最佳答案
您可以使用 iconGravity="textTop"
。
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.TextButton"
app:icon="@drawable/ic_add_24px"
app:iconGravity="textTop" />
注意:它至少需要 1.3.0-alpha02
版本。
关于android - 将图标放在 MaterialButton 中的文本顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62730158/