1.1.1
LayoutX2C 1.1.1
🐛 Bug Fixes
DataBinding ImageView src attribute support
Problem: When using android:src="@{icon}" with DataBinding, the icon was not displayed because the binding code was not being generated.
Root Cause: The ImageSourceAttributeHandler.supportsValue() method rejected DataBinding expressions like "@{icon}" because isSupportedDrawableReference() returned false. This caused android:src to be marked as 'unsupported' instead of 'dataBinding', preventing the binding code from being generated in executeBindings().
Solution: Modified ImageSourceAttributeHandler.supportsValue() to accept DataBinding expressions (@{} and @={}). DataBinding expressions are now validated at runtime via executeBindings() rather than at compile time.
Impact:
- ✅
android:src="@{icon}"now correctly generatesviewIcon.setImageResource(icon ?: 0) - ✅ Static drawable references (
@drawable/xxx) continue to work - ✅ Theme attribute references (
?attr/xxx) continue to work
📝 Changes
Commits
cbcb2aafix: support DataBinding expressions in ImageView android:src attribute7894da7test: fix ImageViewSrcBindingTest array index out of bounds697d204docs(release): split 1.1.0 notes by language5c9a49edocs(release): polish 1.1.0 notes
Modified Files
compiler-core/src/main/kotlin/com/github/donglua/layoutx2c/registry/ViewRegistry.ktcompiler-core/src/test/kotlin/com/github/donglua/layoutx2c/codegen/ImageViewSrcBindingTest.kt- Release documentation improvements
📦 Installation
Gradle (Kotlin DSL)
dependencies {
ksp("com.github.donglua:layoutx2c-ksp:1.1.1")
implementation("com.github.donglua:layoutx2c-runtime:1.1.1")
}Gradle (Groovy)
dependencies {
ksp 'com.github.donglua:layoutx2c-ksp:1.1.1'
implementation 'com.github.donglua:layoutx2c-runtime:1.1.1'
}🔍 How to Verify
After updating to 1.1.1 and rebuilding your project, check the generated binding code:
Before (1.1.0):
protected override fun executeBindings() {
if (dirtyFlags != 0L) {
viewText.setText(text ?: "")
// ❌ Missing: viewIcon.setImageResource(icon ?: 0)
}
}After (1.1.1):
protected override fun executeBindings() {
if (dirtyFlags != 0L) {
viewText.setText(text ?: "")
viewIcon.setImageResource(icon ?: 0) // ✅ Now generated
}
}📖 Full Changelog
v1.1.0...v1.1.1