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

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - How can I merge Nodes & Webform Submissions into instances of one general Content Type in Drupal 6? -