Laughing
android Button动态修改背景图
12/06
本文最后更新于2020年12月06日,已超过1383天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
我们在布局文件中,设置Button的背景图片时,一般是通过如下方式
<ImageButton
android:id="@+id/buttonListTopMenuSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/detail_save"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
/>
如果我们需要动态设置图片,可以通过如下方式
buttonListTopMenuSave = findViewById(R.id.buttonListTopMenuSave);
buttonListTopMenuSave.setBackgroundResource(R.drawable.detail_ok);
buttonListTopMenuSave.setOnClickListener(this);
版权属于:
香草物语
本文链接:
https://www.xiangcaowuyu.net/app/android-button-dynamically-modifies-background-image.html(转载时请注明本文出处及文章链接)
作品采用:
再次强调,垃圾评论不会通过