4

I am using dimen.xml for supporting multiple screen sizes.

How can I access the file and get the dimen from code so can be used in the application?

Yoav

2 Answers 2

11

You can use the following:

float yourDimen = getResources().getDimension(R.dimen.your_dimen_name);
Sign up to request clarification or add additional context in comments.

Comments

3

yes just create different values folder with different qualifiers like res/values-320x480/ , you can use as mention in this link and link2

Resources res = getResources();
float fontSize = res.getDimension(R.dimen.font_size);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.