Should I put all Android view attributes into the style? -


i've seen android devs promote form of declarative layout:

<textview style="@style/my_textview_style" /> 

i.e. pretty attributes (including id) go style definition. makes shorter layout files, step far?

what recommend goes in style definition, , should stay in layout, , why?

i've started doing android dev year, have prior experience of development. issues important, "way" use tools, habits, more efficient. appreciate sharing views on works you, clarity, efficiency, maintainability, app reliability.

i've pondered question , becomes more pertinent when dealing multiple device sizes , densities.

putting information styles can limit use, when dealing landscape , portrait layouts. example landscape layout may in fact wholly different in composition require similar styles.

in these cases helps use . notation ammend style differences, example.

<mypage> <mypage.portrait> <mypage.landscape> 

see below information on above approach creating styles. http://developer.android.com/guide/topics/ui/themes.html

mypage defines common properties layout , override these values in portrait , landscape extensions.

i..e might have more right , left padding in landscape portrait.

the problem i've found themes , styles xml files huge, if me have many activities, , if address lots of creative changes can end lots of messed definitions.

at point have take stock, tidy , re-factor.

my advice plan upfront. define naming system accommodates project, write down , stick it.

possible style naming convention

<section>_<componentname>_<componenttype>_<orientation>  home_leftpanel_btn_horizontal home_leftpanel_listview home_leftpanel_listview_horizontal 

a similar approach themes should adopted.

i'm still working out, can't give fuller examples.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -