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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:28:40+00:00 2026-05-31T13:28:40+00:00

Okay, so i am making an android app that has tabs, now my problem

  • 0

Okay, so i am making an android app that has tabs, now my problem is that the tab widget isn’t uniform across the diffrent android versions or devices.
I want to make it to be the same on any android this is my tab activity

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

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

  TabHost tabHost = getTabHost();

    // Tab for Snacks
    TabSpec snackspec = tabHost.newTabSpec("Snacks");
    // setting Title and Icon for the Tab
    snackspec.setIndicator("Snacks", getResources().getDrawable(R.drawable.cook_icon_tab_snacks));
    Intent snacksIntent = new Intent(this, Cook_tab_snacks.class);
    snackspec.setContent(snacksIntent);



    // Tab for Mains
    TabSpec mainspec = tabHost.newTabSpec("Mains");
    mainspec.setIndicator("Mains", getResources().getDrawable(R.drawable.cook_icon_tab_snacks));
    Intent mainsIntent = new Intent(this, Cook_tab_mains.class);
    mainspec.setContent(mainsIntent);

    // Tab for Desserts
    TabSpec dessertspec = tabHost.newTabSpec("Desserts");
    dessertspec.setIndicator("Desserts", getResources().getDrawable(R.drawable.cook_icon_tab_snacks));
    Intent dessertsIntent = new Intent(this, Cook_tab_desserts.class);
    dessertspec.setContent(dessertsIntent);


    // Adding all TabSpec to TabHost
    tabHost.addTab(snackspec); // Adding snacks tab
    tabHost.addTab(mainspec); // Adding mains tab
    tabHost.addTab(dessertspec); // Adding desserts tab
}

}

I also have my XML layout :

<?xml version="1.0" encoding="UTF-8"?>

<TabHost xmlns:android="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"
    >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:background="@drawable/gradient_bg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>

I made a new indicator xml which is like the main android tab indicator v4
I followed and searched alot of blogs , i couldn’t find my answer …
I really want to make the android tabs uniform across all android versions and to make the colors nice , since orange and yellow dont really fit with the color theme in my app
Help please!!!!
I cant seem to find a way to fix it…
Cheers

  • 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-31T13:28:41+00:00Added an answer on May 31, 2026 at 1:28 pm

    okay i found a solution.
    here is the code:

    import android.app.TabActivity;
    import android.content.Intent;
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TabHost;
    import android.widget.TabHost.TabSpec;
    
    public class Cook extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cook_layout);
    
      TabHost tabHost = getTabHost();
    
        // Tab for Snacks
        TabSpec snackspec = tabHost.newTabSpec("Snacks");
        // setting Title and Icon for the Tab
        snackspec.setIndicator(makeTabIndicator(getResources().getDrawable(R.drawable.cook_icon_tab_snacks)));
        Intent snacksIntent = new Intent(this, Cook_tab_snacks.class);
        snackspec.setContent(snacksIntent);
    
    
    
        // Tab for Mains
        TabSpec mainspec = tabHost.newTabSpec("Mains");
        mainspec.setIndicator(makeTabIndicator( getResources().getDrawable(R.drawable.cook_icon_tab_snacks)));
        Intent mainsIntent = new Intent(this, Cook_tab_mains.class);
        mainspec.setContent(mainsIntent);
    
        // Tab for Desserts
        TabSpec dessertspec = tabHost.newTabSpec("Desserts");
        dessertspec.setIndicator(makeTabIndicator( getResources().getDrawable(R.drawable.cook_icon_tab_snacks)));
        Intent dessertsIntent = new Intent(this, Cook_tab_desserts.class);
        dessertspec.setContent(dessertsIntent);
    
    
        // Adding all TabSpec to TabHost
        tabHost.addTab(snackspec); // Adding snacks tab
        tabHost.addTab(mainspec); // Adding mains tab
        tabHost.addTab(dessertspec); // Adding desserts tab
    }
    
    
    //making the tab view:
    private View makeTabIndicator(Drawable drawable){
    ImageView Tabimage = new ImageView(this);
    LayoutParams LP = new           LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1);
    LP.setMargins(1, 0, 1, 0);
    Tabimage.setLayoutParams(LP);
    Tabimage.setImageDrawable(drawable);
    Tabimage.setBackgroundResource(R.drawable.tabview);
    return Tabimage;
    
    
    }}
    

    I dont know weather or not i need the cook_layout anymore i’ll see if i can remove it or leave it later… right now i just want to get it all working and later i’ll come round by for a clean and tiding up
    hope that helps you guys out there that stumble upon this question! cheers

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

Sidebar

Related Questions

okay im making a layout that has two sides. the left is 30% and
Okay, so I'm making a table right now for Box Items. Now, a Box
Okay, so, I am making a Tumblr client for Android, I've been trying and
okay i'm making a game using c++ (for the engine) and openGL, now i've
Okay, so I'm making an online text-based game, and I'm stuck right now with
Okay, I'm making a project that implements a Double Linked List using classes, templates
Okay, so I am basically making a script to pass post data using cURL.
Okay, I think I'm just making a stupid mistake here, but I want to
Okay so here's what I'm doing. I'm making a request to a server to
Okay, here's the scenario. I have a utility that processes tons of records, 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.