我试图通过a
Drawable
作为参数进入我的
include
.
我已在我的
build.gradle
文件:
android {
dataBinding {
enabled = true
}
....
}
action_bar_button.xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="mysrc" type="android.graphics.drawable.Drawable"/>
</data>
<ImageButton android:id="@+id/notification"
android:background="@null"
android:foreground="?android:attr/actionBarItemBackground"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:padding="15dp"
android:src="@{mysrc}"
android:scaleType="fitCenter"></ImageButton>
</layout>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity"
android:id="@+id/mainlayout">
<include layout="@layout/action_bar_button" app:mysrc="@{@drawable/notification}"/>
</RelativeLayout>
这一直让我在指向
包括
我的声明
activity_main.xml
:
AAPT: error: attribute mysrc (aka com.example.APPNAME:mysrc) not found.
如果我改变
app:mysrc
在里面
activity_main.xml
到
android:mysrc
,它给了我错误:
AAPT: error: attribute android:mysrc not found.
我已经被这个问题困扰了几个小时,并尝试了不少Stack Overflow帖子,但似乎无法解决这个问题。