Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i change the background color for tabs in android?
    text
    copied!<p>i have working with tabs. i want to change the background color or theme for tab. when i click on the tab appears in default color as grey but i want to display that tab in custom color.</p> <p>here my code:</p> <pre><code>&lt;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" android:orientation="vertical" &gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="-30dp" android:background="#FF0000" /&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p>class file is</p> <pre><code>public class AndroidtabActivity extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.main); // View title = getWindow().findViewById(android.R.id.title); // View titleBar = (View) title.getParent(); // titleBar.setBackgroundResource(R.drawable.top_bar2); Resources res = getResources(); TabHost tabHost = getTabHost(); //tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(); //tabHost.setBackgroundResource(R.drawable.pink); TabHost.TabSpec spec; //tabHost.getTabWidget().setDividerDrawable(R.drawable.top_bar); Intent in; in = new Intent().setClass(this, MainActivity.class); spec=tabHost.newTabSpec("calc").setIndicator("calculate").setContent(in); tabHost.addTab(spec); in = new Intent().setClass(this, TutorialZoomActivity1.class); spec=tabHost.newTabSpec("help").setIndicator("help").setContent(in); tabHost.addTab(spec); tabHost.setCurrentTab(2); // spec1.setIndicator("Tab 1",getResources().getDrawable(R.drawable.flash)); } } </code></pre> <p>please tell me how can i change the background color for tabs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload