Android: Using dimen.xml from code

I use dimen.xml to support multiple screen sizes.

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

Yoav

+4
source share
2 answers

You can use the following:

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

yes just create a folder with different values ​​with different qualifiers, such as res / values-320x480 /, you can use link2 as a link

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

All Articles