安卓材质按钮,文字上方有图标。

问题描述 投票:0回答:1

是否可以让一个材质的按钮在其文字上面加一个图标,就像这样。

Buttons

如果可以,你能不能用代码解释一下?

谢谢你。

android kotlin android-button materialbutton
1个回答
1
投票

你可以使用Button属性 "drawableTop "来获得你想要的外观。

android:drawableTop="@drawable/YOUR_DRAWABLE_RESOURCE_NAME"

下面是一个应用它的示例代码。

<Button
     android:id="@+id/your_text_view"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Image"
     android:drawableTop="@drawable/YOUR_DRAWABLE_RESOURCE_NAME"/>
© www.soinside.com 2019 - 2024. All rights reserved.