user1136875
user1136875

Reputation: 613

Android: Using dimen.xml from code

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

Upvotes: 4

Views: 4399

Answers (2)

Dheeresh Singh
Dheeresh Singh

Reputation: 15701

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);

Upvotes: 3

Cat
Cat

Reputation: 67502

You can use the following:

float yourDimen = getResources().getDimension(R.dimen.your_dimen_name);

Upvotes: 11

Related Questions