I like to integrate ads with AppLovin into my Android App.
In their documentation they say:
Declare the base banner height of 50dp in res/values/attrs.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="banner_height">50dp</dimen> </resources>
I also have a dimens.xml present with other <dimen... value's for my app. They work from there as well.
What is the difference between attrs.xml and dimens.xml? What to use in a situation like this?
It doesn't actually matter -
<attr>and<dimen>are both value resources, and you can put them in any file in theres/valuesfolder. They'll all be combined into the same set of resources, so the actual file you use is up to you! So you can do this if you want:and it'll work exactly the same as if you used
attrs.xmlanddimens.xml. It's just convention to putattrs anddeclare-styleablethings in a file calledattrs.xml, all your dimension resources indimens.xml, all your strings instrings.xml...But you don't have to do that, it's up to you! For example, you might want certain resource strings to be stored in a different file, for organisation (maybe they shouldn't be translated). Or maybe some values are common to all configs and you want those in a single file, and you want a separate file for the qualified stuff (that goes in folders based on API level, night theme etc)