error: Error: No resource found that matches the given name (for attribute reference)












1














I have this line in my account_particle.xml layout



            android:padding="?attrs/disc_padding"


this attrs.xml:



<resources>
<declare-styleable name="AccountParticle">
<attr name="apStyle" format="enum">
<enum name="header" value="0"/>
<enum name="list_item" value="1"/>
</attr>

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


</declare-styleable>
</resources>


and this 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>


Why do i get this compilation error?



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


AccountParticle










share|improve this question
























  • Typo. There's no s on attr. That is, it should be android:padding="?attr/disc_padding".
    – Mike M.
    Nov 18 '18 at 9:14










  • but it's on attrs.xml
    – Elad Benda
    Nov 18 '18 at 9:40










  • That's just a file name. The actual resource will be created in the R.attr class. In fact, it doesn't matter what you name any file under the res/values*/ folders, or in which file you put any resource there; they all get processed according to their type, like <attr>.
    – Mike M.
    Nov 18 '18 at 9:43












  • can you write it as an answer?
    – Elad Benda
    Nov 18 '18 at 9:49










  • Sure, I can put that in an answer. Since you intended for it to be attrs, this isn't just a simple typo. Gimme a minute. Thanks!
    – Mike M.
    Nov 18 '18 at 9:55
















1














I have this line in my account_particle.xml layout



            android:padding="?attrs/disc_padding"


this attrs.xml:



<resources>
<declare-styleable name="AccountParticle">
<attr name="apStyle" format="enum">
<enum name="header" value="0"/>
<enum name="list_item" value="1"/>
</attr>

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


</declare-styleable>
</resources>


and this 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>


Why do i get this compilation error?



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


AccountParticle










share|improve this question
























  • Typo. There's no s on attr. That is, it should be android:padding="?attr/disc_padding".
    – Mike M.
    Nov 18 '18 at 9:14










  • but it's on attrs.xml
    – Elad Benda
    Nov 18 '18 at 9:40










  • That's just a file name. The actual resource will be created in the R.attr class. In fact, it doesn't matter what you name any file under the res/values*/ folders, or in which file you put any resource there; they all get processed according to their type, like <attr>.
    – Mike M.
    Nov 18 '18 at 9:43












  • can you write it as an answer?
    – Elad Benda
    Nov 18 '18 at 9:49










  • Sure, I can put that in an answer. Since you intended for it to be attrs, this isn't just a simple typo. Gimme a minute. Thanks!
    – Mike M.
    Nov 18 '18 at 9:55














1












1








1







I have this line in my account_particle.xml layout



            android:padding="?attrs/disc_padding"


this attrs.xml:



<resources>
<declare-styleable name="AccountParticle">
<attr name="apStyle" format="enum">
<enum name="header" value="0"/>
<enum name="list_item" value="1"/>
</attr>

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


</declare-styleable>
</resources>


and this 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>


Why do i get this compilation error?



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


AccountParticle










share|improve this question















I have this line in my account_particle.xml layout



            android:padding="?attrs/disc_padding"


this attrs.xml:



<resources>
<declare-styleable name="AccountParticle">
<attr name="apStyle" format="enum">
<enum name="header" value="0"/>
<enum name="list_item" value="1"/>
</attr>

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


</declare-styleable>
</resources>


and this 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>


Why do i get this compilation error?



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


AccountParticle







android android-layout styles custom-attributes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 8:10







Elad Benda

















asked Nov 17 '18 at 21:35









Elad BendaElad Benda

12.7k59181335




12.7k59181335












  • Typo. There's no s on attr. That is, it should be android:padding="?attr/disc_padding".
    – Mike M.
    Nov 18 '18 at 9:14










  • but it's on attrs.xml
    – Elad Benda
    Nov 18 '18 at 9:40










  • That's just a file name. The actual resource will be created in the R.attr class. In fact, it doesn't matter what you name any file under the res/values*/ folders, or in which file you put any resource there; they all get processed according to their type, like <attr>.
    – Mike M.
    Nov 18 '18 at 9:43












  • can you write it as an answer?
    – Elad Benda
    Nov 18 '18 at 9:49










  • Sure, I can put that in an answer. Since you intended for it to be attrs, this isn't just a simple typo. Gimme a minute. Thanks!
    – Mike M.
    Nov 18 '18 at 9:55


















  • Typo. There's no s on attr. That is, it should be android:padding="?attr/disc_padding".
    – Mike M.
    Nov 18 '18 at 9:14










  • but it's on attrs.xml
    – Elad Benda
    Nov 18 '18 at 9:40










  • That's just a file name. The actual resource will be created in the R.attr class. In fact, it doesn't matter what you name any file under the res/values*/ folders, or in which file you put any resource there; they all get processed according to their type, like <attr>.
    – Mike M.
    Nov 18 '18 at 9:43












  • can you write it as an answer?
    – Elad Benda
    Nov 18 '18 at 9:49










  • Sure, I can put that in an answer. Since you intended for it to be attrs, this isn't just a simple typo. Gimme a minute. Thanks!
    – Mike M.
    Nov 18 '18 at 9:55
















Typo. There's no s on attr. That is, it should be android:padding="?attr/disc_padding".
– Mike M.
Nov 18 '18 at 9:14




Typo. There's no s on attr. That is, it should be android:padding="?attr/disc_padding".
– Mike M.
Nov 18 '18 at 9:14












but it's on attrs.xml
– Elad Benda
Nov 18 '18 at 9:40




but it's on attrs.xml
– Elad Benda
Nov 18 '18 at 9:40












That's just a file name. The actual resource will be created in the R.attr class. In fact, it doesn't matter what you name any file under the res/values*/ folders, or in which file you put any resource there; they all get processed according to their type, like <attr>.
– Mike M.
Nov 18 '18 at 9:43






That's just a file name. The actual resource will be created in the R.attr class. In fact, it doesn't matter what you name any file under the res/values*/ folders, or in which file you put any resource there; they all get processed according to their type, like <attr>.
– Mike M.
Nov 18 '18 at 9:43














can you write it as an answer?
– Elad Benda
Nov 18 '18 at 9:49




can you write it as an answer?
– Elad Benda
Nov 18 '18 at 9:49












Sure, I can put that in an answer. Since you intended for it to be attrs, this isn't just a simple typo. Gimme a minute. Thanks!
– Mike M.
Nov 18 '18 at 9:55




Sure, I can put that in an answer. Since you intended for it to be attrs, this isn't just a simple typo. Gimme a minute. Thanks!
– Mike M.
Nov 18 '18 at 9:55












2 Answers
2






active

oldest

votes


















0














The correct syntax for referring to a theme attribute value in a layout attribute is:



prefix:attribute="?attr/themeAttribute"


That is, attr instead of attrs.



Though you may have defined that attribute in a file named attrs.xml, the filename is actually irrelevant. When resources are being built, every file under the res/values*/ folder is processed, regardless of the filename.



This effectively means that you can name your files there whatever you want, and you can put any resources there in whichever file you want. They will all be processed according to their type, like <attr>, <color>, <string>, etc.






share|improve this answer





























    0














    The issue is related to the attribute usages it should be ?attr/ instead of ?attrs/.





    But you have another issue in your attrs.xml file. The problem is that you are declaring the following reference inside a declare-styleable:



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


    This references should be moved outside the declare-styleable



    Why



    The declare-styleable is used to define a group of attrs that will be used in the context of a custom view. In your case, the disc_padding is used outside the context of an AccountParticle.



    Documentation reference: https://developer.android.com/training/custom-views/create-view#customattr






    share|improve this answer























    • thanks, but i meant the layout is account_particle.xml
      – Elad Benda
      Nov 18 '18 at 8:56










    • @EladBenda I edited my answer ;)
      – André Sousa
      Nov 18 '18 at 19:29











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53355780%2ferror-error-no-resource-found-that-matches-the-given-name-for-attribute-refer%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The correct syntax for referring to a theme attribute value in a layout attribute is:



    prefix:attribute="?attr/themeAttribute"


    That is, attr instead of attrs.



    Though you may have defined that attribute in a file named attrs.xml, the filename is actually irrelevant. When resources are being built, every file under the res/values*/ folder is processed, regardless of the filename.



    This effectively means that you can name your files there whatever you want, and you can put any resources there in whichever file you want. They will all be processed according to their type, like <attr>, <color>, <string>, etc.






    share|improve this answer


























      0














      The correct syntax for referring to a theme attribute value in a layout attribute is:



      prefix:attribute="?attr/themeAttribute"


      That is, attr instead of attrs.



      Though you may have defined that attribute in a file named attrs.xml, the filename is actually irrelevant. When resources are being built, every file under the res/values*/ folder is processed, regardless of the filename.



      This effectively means that you can name your files there whatever you want, and you can put any resources there in whichever file you want. They will all be processed according to their type, like <attr>, <color>, <string>, etc.






      share|improve this answer
























        0












        0








        0






        The correct syntax for referring to a theme attribute value in a layout attribute is:



        prefix:attribute="?attr/themeAttribute"


        That is, attr instead of attrs.



        Though you may have defined that attribute in a file named attrs.xml, the filename is actually irrelevant. When resources are being built, every file under the res/values*/ folder is processed, regardless of the filename.



        This effectively means that you can name your files there whatever you want, and you can put any resources there in whichever file you want. They will all be processed according to their type, like <attr>, <color>, <string>, etc.






        share|improve this answer












        The correct syntax for referring to a theme attribute value in a layout attribute is:



        prefix:attribute="?attr/themeAttribute"


        That is, attr instead of attrs.



        Though you may have defined that attribute in a file named attrs.xml, the filename is actually irrelevant. When resources are being built, every file under the res/values*/ folder is processed, regardless of the filename.



        This effectively means that you can name your files there whatever you want, and you can put any resources there in whichever file you want. They will all be processed according to their type, like <attr>, <color>, <string>, etc.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 18 '18 at 10:04









        Mike M.Mike M.

        29.3k65773




        29.3k65773

























            0














            The issue is related to the attribute usages it should be ?attr/ instead of ?attrs/.





            But you have another issue in your attrs.xml file. The problem is that you are declaring the following reference inside a declare-styleable:



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


            This references should be moved outside the declare-styleable



            Why



            The declare-styleable is used to define a group of attrs that will be used in the context of a custom view. In your case, the disc_padding is used outside the context of an AccountParticle.



            Documentation reference: https://developer.android.com/training/custom-views/create-view#customattr






            share|improve this answer























            • thanks, but i meant the layout is account_particle.xml
              – Elad Benda
              Nov 18 '18 at 8:56










            • @EladBenda I edited my answer ;)
              – André Sousa
              Nov 18 '18 at 19:29
















            0














            The issue is related to the attribute usages it should be ?attr/ instead of ?attrs/.





            But you have another issue in your attrs.xml file. The problem is that you are declaring the following reference inside a declare-styleable:



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


            This references should be moved outside the declare-styleable



            Why



            The declare-styleable is used to define a group of attrs that will be used in the context of a custom view. In your case, the disc_padding is used outside the context of an AccountParticle.



            Documentation reference: https://developer.android.com/training/custom-views/create-view#customattr






            share|improve this answer























            • thanks, but i meant the layout is account_particle.xml
              – Elad Benda
              Nov 18 '18 at 8:56










            • @EladBenda I edited my answer ;)
              – André Sousa
              Nov 18 '18 at 19:29














            0












            0








            0






            The issue is related to the attribute usages it should be ?attr/ instead of ?attrs/.





            But you have another issue in your attrs.xml file. The problem is that you are declaring the following reference inside a declare-styleable:



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


            This references should be moved outside the declare-styleable



            Why



            The declare-styleable is used to define a group of attrs that will be used in the context of a custom view. In your case, the disc_padding is used outside the context of an AccountParticle.



            Documentation reference: https://developer.android.com/training/custom-views/create-view#customattr






            share|improve this answer














            The issue is related to the attribute usages it should be ?attr/ instead of ?attrs/.





            But you have another issue in your attrs.xml file. The problem is that you are declaring the following reference inside a declare-styleable:



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


            This references should be moved outside the declare-styleable



            Why



            The declare-styleable is used to define a group of attrs that will be used in the context of a custom view. In your case, the disc_padding is used outside the context of an AccountParticle.



            Documentation reference: https://developer.android.com/training/custom-views/create-view#customattr







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 18 '18 at 19:29

























            answered Nov 17 '18 at 23:51









            André SousaAndré Sousa

            1,1481818




            1,1481818












            • thanks, but i meant the layout is account_particle.xml
              – Elad Benda
              Nov 18 '18 at 8:56










            • @EladBenda I edited my answer ;)
              – André Sousa
              Nov 18 '18 at 19:29


















            • thanks, but i meant the layout is account_particle.xml
              – Elad Benda
              Nov 18 '18 at 8:56










            • @EladBenda I edited my answer ;)
              – André Sousa
              Nov 18 '18 at 19:29
















            thanks, but i meant the layout is account_particle.xml
            – Elad Benda
            Nov 18 '18 at 8:56




            thanks, but i meant the layout is account_particle.xml
            – Elad Benda
            Nov 18 '18 at 8:56












            @EladBenda I edited my answer ;)
            – André Sousa
            Nov 18 '18 at 19:29




            @EladBenda I edited my answer ;)
            – André Sousa
            Nov 18 '18 at 19:29


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53355780%2ferror-error-no-resource-found-that-matches-the-given-name-for-attribute-refer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?