之前總是莫名其妙地遇到過這種問題,在網上找了不少解決方案,但是還是不知道要怎么解決。求大神告訴原理以及到底要怎么解決的??????
No resouse identifer found for attribute ‘layout_constraintHorizontal_chainStyle’
原因:使用的1.0.8-alpha
版本的源碼里根本沒有Chain
相關屬性的支持,
把alpha7改成compile 'com.android.support.constraint:constraint-layout:1.0.2
在這里附上之前搜集到的解決方案
解決方式:這是我在網上找到的最多的解決方案。
錯誤原因:
布局文件的命名空間沒有添加有包名的命名空間或者添加了錯誤的命名空間。
解決辦法:
命名空間后面的包名應該是AndroidManifest.xml文件中定義的package包名,而不是自定義控件所處的包的包名。
例如:
xmlns:ptr="http://schemas.android.com/apk/res/com.ycii.ljapp.ui", com.ycii.ljapp.ui為AndroidManifest.xml 中定義的 package, 即: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ycii.ljapp.ui" android:versionCode="1" android:versionName="1.0" >
解決要點:要解決這類問題,最主要的是先判斷有沒有導入所用的包,有的時候是因為沒有對應的依賴才出現這樣的問題

錯誤環境2:在使用databinding自定義BindingAdapter出現No resource identifier found for attribute 'XXX' in package XXXXX'問題
@BindingAdapter(value = "is_set_animation") public static void setAnimation(AdapterViewFlipper view, Boolean isTrue) { if(isTrue){ view.setInAnimation(view.getContext(),R.anim.left_in); view.setOutAnimation(view.getContext(),R.anim.left_out); } }
xml代碼:
<AdapterViewFlipper android:layout_width="@dimen/px560" android:layout_height="@dimen/px710" android:flipInterval="5000" android:autoStart="true" bind:itemView="@{fragmentModel.itemView}" bind:items="@{fragmentModel.home_HomeImgList}" bind:on_item_click="@{fragmentModel.HomeImgItemClickListener}" bind:is_set_animation="true" > </AdapterViewFlipper>
錯誤原因:沒有使用databinding的語法
解決方法:
將bind:is_set_animation="true"改成bind:is_set_animation="@{true}"就可以了