1.遇到這個問題大多數(shù)情況下是布局中設(shè)置layout_height,layout_weight,padding等屬性后,沒有重寫對應(yīng)構(gòu)造方法,如下

自定義view中只給了這個構(gòu)造方法

布局屬性設(shè)置
這種情況下,下面報出的異常是Caused by: java.lang.NoSuchMethodException:[class android.content.Context, interface android.util.AttributeSet]
2.還有情況是(個人遇到),對應(yīng)構(gòu)造方法給全,同樣報出了“android.view.InflateException: Binary XML file line # : Error inflating class”,其實是構(gòu)造方法中自己的其他方法出錯引起的

構(gòu)造方法齊全
博主標(biāo)注的這個方法有錯誤,同樣報出了“android.view.InflateException: Binary XML file line # : Error inflating class”,可能給找問題帶來困擾。