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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:46:14+00:00 2026-05-26T18:46:14+00:00

in android tutorial there isn’t a way for customize tab background. my app is

  • 0

in android tutorial there isn’t a way for customize tab background. my app is official-tutorial based..can anyone help me with a tutorial or code for backgroundcolor white?
this is my code:

LauncherActivity.java

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.launcher);

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



        intent = new Intent().setClass(this, MyActivity.class);



        spec = tabHost.newTabSpec("myactivity").setIndicator("Activity")

                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, search.class);
        spec = tabHost.newTabSpec("search").setIndicator("Search"
                          )
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, MyActivity3.class);
        spec = tabHost.newTabSpec("songs").setIndicator("Songs"
                          )
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);
    }

Launcher.xml

   <?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="[url]http://schemas.android.com/apk/res/android"
   android:id="@android:id/tabhost"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
    <LinearLayout
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:padding="5dp">
        <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"/>
        <FrameLayout
           android:id="@android:id/tabcontent"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:padding="0dp" />
    </LinearLayout>
</TabHost>
  • 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-26T18:46:15+00:00Added an answer on May 26, 2026 at 6:46 pm

    If you mean to change background color of tabs,then here is the code:

    for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
    {   
          tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.WHITE); //unselected tab
    }
    

    for selected tab,

    tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.GRAY); // selected tab
    

    You can put above lines into a method (say setTabColors()) and call it:

    tabHost.setOnTabChangedListener(new OnTabChangeListener() {
    
            @Override
            public void onTabChanged(String arg0) {
    
                   setTabColors(tabHost);
            }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if yes, is there a tutorial available for creating an android app using the
Android is based on Linux; can native Linux applications be run on Android?
In one Android Tutorial I saw the usage of this function. There he uses
Is there a good sample application or tutorial for creating android Service that run
Thanks for reading! I am using the Android Gallery tutorial and wondering if there's
I learned from android dev tutorial and now I can make ListView. and it
I am developing apps for ios and android sdk. Is there any tutorial that
My Android tutorial states that I can explicitly tell the TTS engine which stream
I made a list view by the android.com's tutorial, and its in a tab
I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually

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.