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

  • Home
  • SEARCH
  • 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 8860879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:21:48+00:00 2026-06-14T15:21:48+00:00

i’m making an android application, and i have a tabhost and two tabs in

  • 0

i’m making an android application, and i have a tabhost and two tabs in my xml. I have called them and they work just fine. But i want to get rid of the ugly grey/orange color on tabs. I have tried setting the bg using an image. I used this code:

th.getTabWidget().setBackgroundResource(R.drawable.tab_normal);

But it shows up like this:

Wrong bg

How can i get it to replace the gray and orange color?

Thanks

  • 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-14T15:21:49+00:00Added an answer on June 14, 2026 at 3:21 pm

    Steps to fully customize tabwidget:

    1. Create custom layout for tabwidget: this layout similar to default one which consist of one Icon and one TextView. You can choose whatever layout you want. Notice that the parent layout has stateful background tabwidget_selector. This drawable is the key to replace default orange focus color. You can choose your own focus color.

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="40dp"
      android:background="@drawable/tabwidget_selector"
      android:gravity="center"
      android:orientation="vertical" >
      
      <ImageView
          android:id="@+id/tabIndicatorIcon"
          android:layout_width="28dp"
          android:layout_height="28dp"
          android:layout_marginTop="2dp" />
      
      <TextView
          android:id="@+id/tabIndicatorText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginBottom="2dp"
          android:textColor="@color/white" />
      

    2. Write function which return a view for tabwidget. Set text, icon drawable for your tabwidget

      private View getTabIndicatorView(Context context, String tag, int drawable) {
          View view = LayoutInflater.from(context).inflate(
                  R.layout.tab_widget_custom, null);
          TextView tv = (TextView) view.findViewById(R.id.tabIndicatorText);
          tv.setText(tag);
          ImageView tabIndicatorIcon = (ImageView) view
                  .findViewById(R.id.tabIndicatorIcon);
          tabIndicatorIcon.setBackgroundResource(drawable);
          return view;
      
      }
      
    3. Use this function in your activity:

    TabHost.TabSpec setIndicator(View view) Specify a view as the tab
    indicator.

           Intent intent;
            TabHost.TabSpec spec;
    
            spec = tabHost.newTabSpec("Inbox").setIndicator(
                    getTabIndicatorView(MainTabActivity.this, "Hộp thư",
                            R.drawable.tin_nhan_tab_selector));
            intent = new Intent(this, xxxx.InboxActivity.class);
    
            spec.setContent(intent);
            tabHost.addTab(spec);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
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
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.