Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We can achieve this by setting <code>TabSpec</code> content with customized views.Here is the sample.</p> <p>in main.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &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"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;View android:layout_width="fill_parent" android:layout_height="0.5dip" android:background="#000" /&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="0dip" android:layout_marginRight="0dip" /&gt; &lt;View android:layout_width="fill_parent" android:layout_height="2dip" android:background="#696969" /&gt; &lt;View android:layout_width="fill_parent" android:layout_height="2dip" android:background="#000" /&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; &lt;/LinearLayout&gt; </code></pre> <p>in tabs_bg.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabsLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/tab_bg_selector" android:padding="10dip" android:gravity="center" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/tabsText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title" android:textSize="15dip" android:textColor="@drawable/tab_text_selector" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>i use some custom selector for view, you can create on your own.</p> <p>In activity Main.class,</p> <pre><code>private TabHost mTabHost; private void setupTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // construct the tabhost setContentView(R.layout.main); setupTabHost(); mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider); setupTab(new TextView(this), "Tab 1"); setupTab(new TextView(this), "Tab 2"); setupTab(new TextView(this), "Tab 3"); } private void setupTab(final View view, final String tag) { View tabview = createTabView(mTabHost.getContext(), tag); TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(new TabContentFactory() { public View createTabContent(String tag) {return view;} }); mTabHost.addTab(setContent); } private static View createTabView(final Context context, final String text) { View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null); TextView tv = (TextView) view.findViewById(R.id.tabsText); tv.setText(text); return view; } </code></pre> <p>which provide output like this...<img src="https://i.stack.imgur.com/SYkjD.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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