css - Storing dimensions in xml file in Android -


i trying consistently use same dimension in views in android app (e.g., left margin of 20dp). if using html, use css file, @ loss of how on android.

is there way can store value in xml file inside res/values , use in layouts?

e.g., thought of storing them in strings.xml like

<string name="app_wide_left_padding">20dp</string> 

and using following text in layout.xml

android:paddingleft="@string/app_wide_left_padding" 

but not sure work. on right track?

thanks in advance answers.

create file called res/values/dimens.xml

<?xml version="1.0" encoding="utf-8"?> <resources>     <dimen name="icon_width">55dip</dimen>     <dimen name="icon_height">55dip</dimen>     <dimen name="photo_width">170dip</dimen>     <dimen name="photo_height">155dip</dimen> </resources> 

then reference them in other xml:

android:padding="@dimen/icon_width"> 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -