android - ImageButton 会导致未解决的 R 吗?
问题描述
试图创建一个带有几个 ImageButtons 的应用程序来播放声音。由于我添加到drawable文件夹的图像很大,认为它们会造成麻烦;因此使用启动器图像进行了测试,但出现了相同的错误。受够了这个烦人的麻烦..请提出一条出路..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="28dp"
android:layout_marginLeft="28dp"
android:layout_marginTop="26dp"
android:background="null"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
app:srcCompat="@mipmap/ic_launcher_round" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageButton1"
android:layout_centerHorizontal="true"
android:background="null"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
app:srcCompat="@mipmap/ic_launcher" />
</RelativeLayout>
解决方案
我认为您的背景属性存在问题。您不能在背景属性中提供“null”值。
请试试
android:background="@null"
它可能会帮助你。
推荐阅读
- reactjs - 为 react-redux 转换为 ES6 类版本的 Private Route 功能代码
- angular - 使用 Spring Boot 部署 Angular 应用程序(在 AWS 上)
- jhipster - 如何添加屏幕以查看 Jhipster 中的实例日志?
- java - 在存在的 Firebase 用户上获取 NullPointerException
- javascript - 如何在 ExpressJS 中逐行上传和读取大文件?
- gnuplot - gnuplot:如何使用“不均匀”数据获得正确的等高线水平值?
- sql-server - TSQL 查询 - 如何让 WHERE 条件“加起来”?
- c# - 错误 MSB3325:无法导入以下密钥文件:csc.pfx。密钥文件可能受密码保护
- php - 使用 php 在 API 的 url 中传递日期/日期时间
- python - 将给定变量与 Python 中结构化 JSON 中的值匹配