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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:06:03+00:00 2026-06-10T09:06:03+00:00

From API level 11 setDividerDrawable() and setShowDividers() was introduced on LinearLayout , enabling the

  • 0

From API level 11 setDividerDrawable() and setShowDividers() was introduced on LinearLayout, enabling the linear layout to show dividers between child elements. I would really like to use this feature, but I am also targeting devices before Honeycomb (API level < 11).

One way to fix this is to extend LinearLayout and add the divider manually. This is a prototype:

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

public class DividerLinearLayout extends LinearLayout
{
    public DividerLinearLayout(Context context)
    {
        super(context);
    }

    public DividerLinearLayout(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    public DividerLinearLayout(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
    }

    @Override
    public void addView(View child)
    {
        if(super.getChildCount() > 0)
        {
            super.addView(LayoutInflater.from(getContext()).inflate(R.layout.divider, null));
        }
        super.addView(child);
    }
}

However, using such an implementation will change the behavior of any clients iterating over the children. Some views will be the ones inserted by the client himself, some will be inserted by the DividerLinearLayout. Problems will also happen if the user is inserting views at specified indexes. One could implement a conversion of indexes, but this could lead to nasty errors if done wrong. Also, I think a lot more of the methods needs to be overridden.

Is there any better way of solving the problem? Has someone already developed a freely usable DividerLinearLayout equivalent? It does not seem to exist in the compatibility libraries for Android.

  • 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-06-10T09:06:05+00:00Added an answer on June 10, 2026 at 9:06 am

    If I’m not mistaken, the ActionBarSherlock library already implemented this to provide backwards compatible ActionBar tabs. You might want to include that library first and give it a whirl before rolling your own.

    This is the code for the specific class (com.actionbarsherlock.internal.widget.IcsLinearLayout).

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

Sidebar

Related Questions

I want to use in my application classes from API Level 11. Which in
When I create a new Android Sample Project from eclipse with api level 14,
I quote from the SDK docs: Beginning with Android 3.0 (API level 11), Android-powered
I am aware that from API level 5 it is possible to specify a
Android API level 8 introduced the Context.getExternalFilesDir() method, providing a File object reference to
I would like to implement a switch button, android.widget.Switch (available from API v.14). <Switch
from fabric.api import sudo, put, run def install(): run('source /home/user/.virtualenvs/demo/bin/activate') run('pip install requests') if
From LinkedIn API I got this hash: > #<LinkedIn::Mash all=[#<LinkedIn::Mash api_standard_profile_request=#<LinkedIn::Mash headers=#<LinkedIn::Mash > all=[#<LinkedIn::Mash
I am calling an API from a Rails model and I would like to
I need to use Twitter api from iPhone 3.0 (SDK 3.0). can i use

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.