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 5933649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:00:11+00:00 2026-05-22T15:00:11+00:00

I am interested in creating a ListView where each row is marked the way

  • 0

I am interested in creating a ListView where each row is marked the way it is done in GMail for 3.0+. This creates a nice separation of the left and right ListFragment.

Other examples include also Google Calendar on 2.3.4 for instance where a color marker is on the left of the ListView.

GMail ListView

See the grey vertical divider between the two lists. How does one achive something like this? A bonus would be also the alternating width, but I guess that is only a smaller layout change.

I know I could probably do something like inserting an ImageView in there and then fill it with the color I would like but it seems to me that this is an ugly hack.

Another question would be also if there is a generalized way to combine the two ListView fragments somehow the way the GMail or Mail applications do it.

GMail ListView across two fragments

  • 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-22T15:00:12+00:00Added an answer on May 22, 2026 at 3:00 pm

    If you want speed, then the option I would go for is to use a custom View class (e.g. extend RelativeLayout) for the row container View and override the dispatchDraw(Canvas canvas) method.

    The dispatchDraw method is called after the View has drawn its own contents and before it draws its children – the children are drawn when you call super.dispatchDraw.

    Use this to do something like

    private boolean mDrawMarker = false;
    
    public void setShouldDrawMarker(boolean drawMarker) {
        mDrawMarker = drawMarker;
    }
    public boolean getShouldDrawMarker() {
        return mDrawMarker;
    }
    
    @Override
    public void dispatchDraw(Canvas canvas) {
        // draw the children of our view 
        super.dispatchDraw(canvas);
    
        // draw our marker on top of the children if needed
        if (mDrawMarker) {
            // e.g. canvas.drawRect(...) or canvas.drawBitmap(...)
        }
    }
    

    This way you avoid adding any extra views to the hierarchy which means you won’t incur any penalty in the layout or measuring phases. Remember to re-use Paint and Rect objects if drawing a rectangle rather than creating a new one each time. Similarly if you use a bitmap you should share the same Bitmap instance across all instances of your View rather than loading a new one from your resources each time (this does not mean putting them in static fields)

    For the indentation of the items, since in this case the lists don’t seem to be overlapping you could (off the top of my head):

    • Set a left margin on the row container (not totally sure this will work)
    • Wrap the row container in a LinearLayout and set the left padding on this (if the above doesn’t work)
    • Use a custom view class (if setting the left margin doesn’t work)
    • Go with @commonsware suggestion and use two Views – one on the left with the grey background color and another to the right of that with the marker color – then just set the view on the left to visible/gone if you want indentation/no-indentation

    As for the overlapping of the Views in the second example, I’ll defer to @commonsware answer.

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

Sidebar

Related Questions

I'm interested in creating a plugin that does this simple task: Steps 1. User
I'm interested to find which way of creating box shadows with css is most
I am interested if creating a new std::vector (or calling its assign method) creates
I'm interested in creating a macro for eliminating the unused variable warning. This question
So I'm interested in creating a custom context menu for each of my list
I am interested in creating a form in an iphone application similar to this
I'm interested in creating a game that uses fractal maps for more realistic geography.
I am interested in creating a website entirely in silverlight (personal reasons) but I
I'm interested in creating a sort of hand-off authentication method, where there's a client
I am interested in creating a web app that uses JSP , Servlets and

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.