Clans / FloatingActionButton

Android Floating Action Button based on Material Design specification
Apache License 2.0
5.23k stars 1.13k forks source link

I'm getting android.view.InflateException error #407

Closed Gurleen9 closed 7 years ago

Gurleen9 commented 7 years ago

i get android.view.InflateException: Binary XML file line #49: Binary XML file line #49: Error inflating class com.github.clans.fab.FloatingActionButton error

What could be the reason?

Gurleen9 commented 7 years ago

java.lang.NoSuchFieldError: FloatingActionButton_fab_colorNormal   at com.getbase.floatingactionbutton.FloatingActionButton.init(FloatingActionButton.java:76)   

This is the error

chenfd99 commented 7 years ago

在 android4.0.4 上报错 找不到 xml 图片????

chenfd99 commented 7 years ago

当我使用 app:srcCompat 时 android4.0.4上不报错 但是不显示图片 当我使用 android:src 的时候 android7.0 可以显示图片不报错 但android 4.0.4 报错

chenfd99 commented 7 years ago

https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88

huseyinbarin commented 7 years ago

The reason is the in " init(Context context, AttributeSet attrs, int defStyleAttr) " method of FloatingActionButton.class.

R.styleable.FloatingActionButton_fab_colorNormal is not found in your attrs.xml file

insert these to your attrs.xml file

  <declare-styleable name="FloatingActionButton">
    <attr name="fab_colorNormal" format="color" />
    <attr name="fab_colorPressed" format="color" />
    <attr name="fab_colorDisabled" format="color" />
    <attr name="fab_colorRipple" format="color" />
    <attr name="fab_showShadow" format="boolean" />
    <attr name="fab_shadowColor" format="color" />
    <attr name="fab_shadowRadius" format="dimension" />
    <attr name="fab_shadowXOffset" format="dimension" />
    <attr name="fab_shadowYOffset" format="dimension" />
    <attr name="fab_size" format="enum">
      <enum name="normal" value="0" />
      <enum name="mini" value="1" />
    </attr>
    <attr name="fab_showAnimation" format="reference" />
    <attr name="fab_hideAnimation" format="reference" />
    <attr name="fab_label" format="string" />
    <attr name="fab_elevationCompat" format="dimension" />
    <attr name="fab_progress_color" format="color" />
    <attr name="fab_progress_backgroundColor" format="color" />
    <attr name="fab_progress_indeterminate" format="boolean" />
    <attr name="fab_progress_max" format="integer" />
    <attr name="fab_progress" format="integer" />
    <attr name="fab_progress_showBackground" format="boolean" />
  </declare-styleable>

  <declare-styleable name="FloatingActionMenu">
    <attr name="menu_showShadow" format="boolean" />
    <attr name="menu_buttonSpacing" format="dimension" />
    <attr name="menu_labels_margin" format="dimension" />
    <attr name="menu_labels_showAnimation" format="reference" />
    <attr name="menu_labels_hideAnimation" format="reference" />
    <attr name="menu_labels_paddingTop" format="dimension" />
    <attr name="menu_labels_paddingLeft" format="dimension" />
    <attr name="menu_labels_paddingRight" format="dimension" />
    <attr name="menu_labels_paddingBottom" format="dimension" />
    <attr name="menu_labels_padding" format="dimension" />
    <attr name="menu_labels_textColor" format="reference|color" />
    <attr name="menu_labels_textSize" format="dimension" />
    <attr name="menu_labels_cornerRadius" format="dimension" />
    <attr name="menu_labels_showShadow" format="boolean" />
    <attr name="menu_labels_colorNormal" format="color" />
    <attr name="menu_labels_colorPressed" format="color" />
    <attr name="menu_labels_colorRipple" format="color" />
    <attr name="menu_labels_position" format="enum">
      <enum name="left" value="0" />
      <enum name="right" value="1" />
    </attr>
    <attr name="menu_icon" format="reference" />
    <attr name="menu_animationDelayPerItem" format="integer" />
    <attr name="menu_buttonToggleAnimation" format="reference" />
    <attr name="menu_labels_singleLine" format="boolean" />
    <attr name="menu_labels_ellipsize" format="enum">
      <enum name="none" value="0" />
      <enum name="start" value="1" />
      <enum name="middle" value="2" />
      <enum name="end" value="3" />
      <enum name="marquee" value="4" />
    </attr>
    <attr name="menu_labels_maxLines" format="integer" />
    <attr name="menu_fab_size" format="enum">
      <enum name="normal" value="0" />
      <enum name="mini" value="1" />
    </attr>
    <attr name="menu_labels_style" format="reference" />
    <attr name="menu_labels_customFont" format="string" />
    <attr name="menu_shadowColor" format="color" />
    <attr name="menu_shadowRadius" format="dimension" />
    <attr name="menu_shadowXOffset" format="dimension" />
    <attr name="menu_shadowYOffset" format="dimension" />
    <attr name="menu_colorNormal" format="color" />
    <attr name="menu_colorPressed" format="color" />
    <attr name="menu_colorRipple" format="color" />
    <attr name="menu_openDirection" format="enum">
      <enum name="up" value="0" />
      <enum name="down" value="1" />
    </attr>
    <attr name="menu_backgroundColor" format="color" />
    <attr name="menu_fab_label" format="string" />
    <attr name="menu_fab_show_animation" format="reference" />
    <attr name="menu_fab_hide_animation" format="reference" />
  </declare-styleable>