【问题标题】:custom attribute not found in my custom View在我的自定义视图中找不到自定义属性
【发布时间】:2018-11-18 08:54:12
【问题描述】:

我的 account_particle.xml 布局中有这一行

            android:padding="?attrs/disc_padding"

这个 attrs.xml:

<resources>
  <declare-styleable name="AccountParticle">

    <attr name="text_margin_start" format="reference"/>
    <attr name="disc_padding" format="reference"/>
    <attr name="disc_imageViewSize" format="reference"/>


  </declare-styleable>
</resources>

还有这个styles.xml:

<style name="Theme.ap.header" parent="Theme.AppCompat">
    <item name="disc_padding">@dimen/account_menu_header_signed_in_avatar_margin_start</item>
  </style>

  <style name="Theme.ap.list_item" parent="Theme.AppCompat">
    <item name="disc_padding">@dimen/account_menu_account_list_item_avatar_margin_start</item>



      </style>

为什么会出现这个编译错误?

 error: Error: No resource found that matches the given name (at 'padding' with value '?attrs/disc_padding').

帐户粒子

【问题讨论】:

    标签: android styles android-custom-view custom-attributes


    【解决方案1】:

    尝试替换android:padding="?attrs/disc_padding"

    android:padding="?attr/disc_padding"android:padding="?disc_padding"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 1970-01-01
      • 2013-01-25
      • 2011-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多