No resource found that matches the given name (at 'paddingBottom' with value '@dimen/ activity_vertical_margin')

后端 未结 3 1768
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 07:45

I was trying to build a navigation drawer for which I copied code from some website and I am getting this error in one of the XMLs.

No resource found

相关标签:
3条回答
  • 2021-01-03 08:26
    1. Go to Android view of the project
    2. go to app -> res -> values.
    3. Right click on values
    4. Then "New" (right at the top of the pop-up menu), "Value resource file".
    5. In the "file name" space, type "dimens.xml" (without the quotation marks " ")
    6. Then simply "Ok".

    Click on the newly created "dimens.xml" file. Remove all code in it and paste the following:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <dimen name="activity_vertical_margin">8dp</dimen>
        <dimen name="activity_horizontal_margin">8dp</dimen>
    </resources>
    

    that's should work

    0 讨论(0)
  • 2021-01-03 08:32

    Make sure you copied the dimens.xml file too.

    0 讨论(0)
  • 2021-01-03 08:33

    In some project templates you find app/src/main/res/values/dimens.xml with only one value:

    <resources>
        <dimen name="fab_margin">16dp</dimen>
    </resources>
    

    So you need to add the missing ones to that file:

    <resources>
        <dimen name="fab_margin">16dp</dimen>
        <dimen name="activity_horizontal_margin">16dp</dimen>
        <dimen name="activity_vertical_margin">16dp</dimen>
    </resources>
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题