更改按钮中的图像
本文关键字:图像 按钮 | 更新日期: 2023-09-27 18:02:07
如何更改按钮中的图像?在我的情况下,如何用另一个图像改变"@drawable/notConnected"
?有什么办法可以做到吗?
这是我的xml
<Button
android:text="CONNECTION"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/notConnected"
android:id="@+id/wifiButton" />
我认为您希望以编程方式更改。当您使用drawableRight
属性来设置图像时,您必须:
wifiButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.newImage, 0);
希望有帮助!