Android puts TabHost at the bottom to display

Source: Internet
Author: User

Layout file:

<?xml version="1.0" encoding="utf-8"?><TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"  xmlns:android="http://schemas.android.com/apk/res/android">    <LinearLayout android:orientation="vertical" android:id="@id/ll_main_tab" android:layout_width="fill_parent" android:layout_height="fill_parent">        <FrameLayout android:gravity="center" android:id="@android:id/tabcontent" android:fadingEdge="none" android:fadingEdgeLength="0.0dip" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">        <RelativeLayout android:id="@+id/tabFirst"              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:orientation="vertical">           <AnalogClock              android:id="@+id/widget31"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_centerInParent="true">           </AnalogClock>           </RelativeLayout>         <RelativeLayout android:id="@+id/tabSecond"              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:orientation="vertical">               <DigitalClock                  android:layout_centerInParent="true"                  android:layout_width="wrap_content"                  android:layout_height="wrap_content">               </DigitalClock>           </RelativeLayout>                              </FrameLayout>        <TabWidget android:id="@android:id/tabs" android:background="@drawable/tab_btn_bg_normal" android:layout_width="fill_parent" android:layout_height="wrap_content" />    </LinearLayout></TabHost>

Code area:

package com.tanghy.tab.activity;import android.app.TabActivity;import android.content.Intent;import android.os.Bundle;import android.widget.TabHost;public class MainActivity extends TabActivity {TabHost tabHost;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);                tabHost = getTabHost();                tabHost.addTab(tabHost.newTabSpec("one").setIndicator("aaaa").setContent(R.id.tabFirst));        tabHost.addTab(tabHost.newTabSpec("two").setIndicator("bbb").setContent(R.id.tabSecond));        tabHost.addTab(tabHost.newTabSpec("three").setIndicator("ccc").    setContent(new Intent().setClass(this, LogActivity.class)));                tabHost.setCurrentTab(0);            }}

The Code shows that we can use the view id to set a menu or use intent to set a display interface.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.