android - 如何将前景图像设置为 ImageButton?
问题描述
我是 Android 应用程序开发的新手。我想在 API 级别 19 中将前景图像设置为图像按钮。如何执行此操作?
解决方案
对于示例代码,将其用于 1 个答案的布局:
<FrameLayout
android:id="@+id/answer_section"
android:layout_width="100dp"
android:layout_height="100dp">
<ImageView
android:id="@+id/answer_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/house_img"/>
<ImageView
android:id="@+id/answer_check"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/check_img"/>
</FrameLayout>
您对 2 张图像使用 2 种不同ImageView
的图像,以便它们可以单独工作,例如制作动画、显示/隐藏条件......
推荐阅读
- java - 与命令行程序通信 Java vs C
- flutter - Flutter:更改 GestureRecognizers
- laravel - 如何使用 PHP 变量设置刀片表达式?
- gist - Github Gists 和 Pastebin 有什么区别?
- php - Mysql查询逻辑(当然之前,之后,之间)
- r - 从数据框中子集数据并从子集值中获取特定值
- python - 尝试在应用程序之间使用 pyserial,但我得到了终端
- java - Java Spring 国际化(i18n)问题
- angular - 无法将 Angular Google Maps (AGM) 添加到 Jhipster
- pandas - 如何在另一个数据帧上通过类似 vlookup 的过程创建新的 pandas 列