为 ImageButton 添加背景 Android
Adding background to ImageButton Android
我有一个问题显示:
Error:(19, 29) No resource found that matches the given name
(at 'background' with value '@drawable/unpressed').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'Drive:\Users\...\sdk\build-tools.0.1\aapt.exe'' finished with non-zero exit value 1
基本上我想给 ImageButton 添加背景,它会在 OnTouch()
事件后改变。首先,我必须添加一个图像(没有事件的简单场景)
我在一个简单的案例中遇到了上述问题。我不知道我犯了什么错误。我的 ImageButton 代码是:
<ImageButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="202dp"
android:background="@drawable/unpressed"
/>
我已经尝试了搜索到的所有解决方案,包括:
清洁溶液
重建解决方案
更新SDK(在STACK解决方案中提到)库
文件>无效Caches/Restart
在 drawable
中粘贴图像后,将其同步。
正如 iGoda 在评论中告知的那样。如何找到 R 设置的确切更改位置?
久违了,问题解决了:
- 正在删除路径中的文件:
C:\Users\UserName\AppData\Local\Temp
如果您看不到上述路径中的任何文件夹,请进入 Windows 资源管理器菜单栏中的以下选项以显示隐藏文件:Organize -> Folder and Search Options
(对于Windows-7)
- 重启系统再检查。一切都会好起来的。
我有一个问题显示:
Error:(19, 29) No resource found that matches the given name
(at 'background' with value '@drawable/unpressed').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'Drive:\Users\...\sdk\build-tools.0.1\aapt.exe'' finished with non-zero exit value 1
基本上我想给 ImageButton 添加背景,它会在 OnTouch()
事件后改变。首先,我必须添加一个图像(没有事件的简单场景)
我在一个简单的案例中遇到了上述问题。我不知道我犯了什么错误。我的 ImageButton 代码是:
<ImageButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="202dp"
android:background="@drawable/unpressed"
/>
我已经尝试了搜索到的所有解决方案,包括:
清洁溶液
重建解决方案
更新SDK(在STACK解决方案中提到)库
文件>无效Caches/Restart
在
drawable
中粘贴图像后,将其同步。
正如 iGoda 在评论中告知的那样。如何找到 R 设置的确切更改位置?
久违了,问题解决了:
- 正在删除路径中的文件:
C:\Users\UserName\AppData\Local\Temp
如果您看不到上述路径中的任何文件夹,请进入 Windows 资源管理器菜单栏中的以下选项以显示隐藏文件:
Organize -> Folder and Search Options
(对于Windows-7)- 重启系统再检查。一切都会好起来的。