我在使用app:srcCompat &的Support Lib v23.2中使用新矢量可繪製支持,試圖通過數據綁定設置其可繪製。與srcCompat的數據綁定
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="mediaPojo"
type="in.ishaan.pika.data_binding.MediaPojo"/>
</data>
<RelativeLayout
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
... />
<ImageView
...
app:srcCompat="@{mediaPojo.isPlaying ? @drawable/ic_pause_24dp : @drawable/ic_play_arrow_24dp}"
/>
<ProgressBar
.../>
</RelativeLayout>
</layout>
在試圖建立,工作室拋出:
Error:(33, 30) Cannot find the setter for attribute 'app:srcCompat' with parameter type android.graphics.drawable.Drawable.
您是否在佈局的根元素上包含'xmlns:app =「http://schemas.android.com/apk/res-auto」'屬性? –
@PaulDS是的,讓我用全佈局更新這個問題 –