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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:18:38+00:00 2026-06-12T13:18:38+00:00

I am using tabhost in my application. Can we give separate width property for

  • 0

I am using tabhost in my application. Can we give separate width property for each tab? i.e, one with larger width and other with smaller?please give me sample example.if possible means give me code.

EDIT:

public class TabBarSimple extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);



    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    TabSpec dbspec = tabHost.newTabSpec("DashBoard");
    dbspec.setIndicator("Dashboard", getResources().getDrawable(R.drawable.dashboard));

    Intent dbIntent = new Intent(this, PhotosActivity.class);
    dbspec.setContent(dbIntent);
    tabHost.addTab(dbspec);

    TabSpec orderspec = tabHost.newTabSpec("Orders");
    orderspec.setIndicator("Orders", getResources().getDrawable(R.drawable.orders));

    Intent orderIntent = new Intent(this, SongsActivity.class);
    orderspec.setContent(orderIntent);
    tabHost.addTab(orderspec);
    TabSpec settingspec = tabHost.newTabSpec("Customers");
    settingspec.setIndicator("Customers", getResources().getDrawable(R.drawable.customers));
    Intent settingIntent = new Intent(this, VideosActivity.class);
    settingspec.setContent(settingIntent);
    tabHost.addTab(settingspec);
    TabSpec aboutspec = tabHost.newTabSpec("Settings");
    aboutspec.setIndicator("Settings", getResources().getDrawable(R.drawable.settings));
    Intent aboutIntent = new Intent(this, PhotosActivity.class);
    aboutspec.setContent(aboutIntent);
    tabHost.addTab(aboutspec);
    TabSpec logoutspec = tabHost.newTabSpec("Logout");
    logoutspec.setIndicator("Logout", getResources().getDrawable(R.drawable.logout));
    Intent logoutIntent = new Intent(this, SongsActivity.class);
    logoutspec.setContent(logoutIntent);
    tabHost.addTab(logoutspec);


    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
    {
    //tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#8A4117"));
    tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_indicator);
    tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 100;
    tabHost.getTabWidget().getChildAt(1).getLayoutParams().width = 50;
    }
    tabHost.getTabWidget().setCurrentTab(0);
    //tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#C35817"));
    tabHost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.tab_indicator);

     }

    public void onTabChanged(String tabId) {
          TabHost tabHost = getTabHost();
    // TODO Auto-generated method stub
    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
    {
    //tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#8A4117"));
    tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_indicator);
    }
    //tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#C35817"));
    tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundResource(R.drawable.tab_indicator);
    }

     }
  • 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-12T13:18:39+00:00Added an answer on June 12, 2026 at 1:18 pm

    You can achieve this by the code below -:

    tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 50;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a TabHost which has 3 tabs. Each tab has a image
I have two tabs using tabhost. One tab having activity extends ExpandableListActivity. It works
Possible Duplicate: Separate Back Stack for each tab in Android using Fragments I've recently
I have an application with various tabs (on a tabhost), each tab is an
Can some one please assist me in this example of TabHost? The problem i
I have implemented 3 Tabs in my applications using TabHost and TabActivity. Each Tab
I have an application with TabHost with few tabs and in each tab I
I am using tabs in my application . Each tab is pointing to 3
I am using TabHost in my application. When I use ProgressBar in any one
I am using TabHost in my application. When I click on any one of

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.