Question

Is it possible to use the reference of a dimension resource in another dimension? What i mean is something like this:

File dimen.xml:

<dimen name="test1">18sp</dimen>
<dimen name="test2">@dimen/test1</dimen>
Was it helpful?

Solution

It works the way i posted

<dimen name="test1">18sp</dimen>
<dimen name="test2">@dimen/test1</dimen>

OTHER TIPS

I would suggest to consider one more thing when using this. I get what you said in your comment, but either there is a link between the two values or there is not and you should distinguish between these two possibilities.

If there is no link between test1 and test2 and they are independent and the fact that they hold the same value is mere coincidence, then you shouldnt suggest a link between the two. Instead just set the same value twice.

Why do you want create a second dimension with the same value as first ?

Don't create second dimension, but use first !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top