How can I make a measurement a multiple of another measurement?

I was wondering if the measurement can be made more complex for another dimension in Android. For example, I can do something like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="base">50dp</dimen>
    <dimen name="size_of_something">4*@dimen/base</dimen>
</resources>

I am currently using a workaround as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="base_x1">50dp</dimen>
    <dimen name="base_x2">100dp</dimen>
    <dimen name="base_x3">150dp</dimen>
    <dimen name="base_x4">200dp</dimen>
    <!-- etc... -->
    <dimen name="size_of_something">@dimen/base_x4</dimen>
</resources>

But this means that I have to update all multiples every time I change the size of the database, which is not only cumbersome, but also error prone.

+3
source share

All Articles