简体   繁体   English

按钮可绘制图标未显示

[英]Button drawable icon not showing

I am trying to display a normal icon on before the text on the button. 我试图在按钮上的文本之前显示一个普通的图标。 I know how it should work and I don't know why it doesn't. 我知道它应该如何工作,我也不知道为什么它不起作用。

Things I have already tried: 我已经尝试过的事情:

  • most basic and isolated button 最基本和孤立的按钮
  • multiple or no styles 多种样式或无样式
  • multiple icons 多个图标
  • all stack overflow answers I could find didn't work for me 我能找到的所有堆栈溢出答案都不适用于我

Here is the code I use: 这是我使用的代码:

<Button
    style="@style/Widget.MaterialComponents.Button.OutlinedButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:drawableStart="@drawable/ic_check_black_24dp"
    android:text="Button with Left Icon" />

Any tips on what I could try or how I could make a button with icon differently? 关于我可以尝试的方式或如何使带图标的按钮不同的任何提示?

Try like this 这样尝试

<com.google.android.material.button.MaterialButton
    android:id="@+id/btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TEXT"
    style="@style/Widget.AppCompat.Button.Borderless"
    app:icon="@drawable/ic_refresh_black_24dp"

    />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM