Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:37:13+00:00 2026-05-18T07:37:13+00:00

I’ve seen that some Android devs promote this form of declarative layout: <TextView style=@style/my_textview_style

  • 0

I’ve seen that some Android devs promote this form of declarative layout:

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

i.e. that pretty much all the attributes (including the ID) go into the style definition. It certainly makes for shorter layout files, but is it a step too far?

What would you recommend goes in the style definition, and what should stay in the layout, and why?

I’ve started doing Android dev this year, but have prior experience of development. Issues like this are so important, the “way” we use the tools, the habits, to be more efficient. I appreciate you sharing your views on what works for you, for clarity, for efficiency, for maintainability, for app reliability.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:37:14+00:00Added an answer on May 18, 2026 at 7:37 am

    I’ve pondered this very question and it becomes much more pertinent when dealing with multiple device sizes and densities.

    Putting too much information into the styles can limit their use, especially when dealing with landscape and portrait layouts. For example a landscape layout may in fact be wholly different in composition but require very similar styles.

    In these cases it helps to use the . notation to ammend style differences, for example.

    <MyPage>
    <MyPage.portrait>
    <MyPage.landscape>
    

    See below for information on the above approach to creating styles.
    http://developer.android.com/guide/topics/ui/themes.html

    MyPage defines the common properties for your layout and you then override these values in the portrait and landscape extensions.

    I..e you might have more right and left padding in landscape than portrait.

    The problem i’ve found is that the themes and styles xml files get huge, especially if like me you have many activities, and if you address lots of creative changes then you can end up with lots of messed up definitions.

    At this point you have to take stock, tidy up and re-factor.

    My only advice is that you plan really well upfront. Define a naming system that accommodates your project, write it down and stick to it.

    Possible style naming convention

    <section>_<componentName>_<componentType>_<orientation>
    
    home_leftPanel_btn_horizontal
    home_leftPanel_listview
    home_leftPanel_listview_horizontal
    

    A similar approach to themes should be adopted.

    I’m still working this out, so can’t give fuller examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.