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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:50:45+00:00 2026-05-26T02:50:45+00:00

I tried to create a tabbed Android app, but got stuck with one strangle

  • 0

I tried to create a tabbed Android app, but got stuck with one strangle behavior: the tab content fills the whole screen (ie behind the tabs as well), instead of just underneath the tab. However, when I click different tabs, it does switch the content. So, I guess I just missed a minor tweak. Here is my code (clutter removed). Hope somebody will spot my mistakes.

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

        TabHost tabHost = getTabHost();     

        tabHost.addTab(tabHost.newTabSpec("Date").setIndicator("Date").setContent(new Intent(this, DateActivity.class)));      
        tabHost.addTab(tabHost.newTabSpec("Time").setIndicator("Time").setContent(new Intent(this, TimeActivity.class)));
        tabHost.setCurrentTab(0); 

        int n = tabHost.getTabWidget().getChildCount(); 
        for (int i = 0; i < n; i++)   
            tabHost.getTabWidget().getChildAt(i).getLayoutParams().height /= 2;        
    }
}


<?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">
    <RelativeLayout
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:padding="3dp">
       <FrameLayout
           android:id="@android:id/tabcontent"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:layout_weight="1" />
       <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_alignParentTop="true"
           />
    </RelativeLayout>
</TabHost>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:padding="2pt"
    android:background="@color/myColor">

    <DatePicker android:id="@+id/datePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content"></DatePicker>
</LinearLayout>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TimePicker android:id="@+id/timePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TimePicker>    
</LinearLayout>


public class DateActivity extends Activity{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.date);        
}

public class TimeActivity extends Activity  {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.time);
    }
}

    <application android:icon="@drawable/icon" android:label="@string/app_name" 
        android:theme="@android:style/Theme.Black.NoTitleBar">
        <activity android:name=".MainActivity" 
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".DateActivity"></activity>
        <activity android:name=".TimeActivity"></activity>
        <activity android:name=".DateTimeActivity"></activity>
    </application>
  • 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-26T02:50:46+00:00Added an answer on May 26, 2026 at 2:50 am

    You should use a LinearLayout instead of your RelativeLayout inside your TabHost. Also set the android:layout_weight="0" for your TabWidget.

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

Sidebar

Related Questions

I tried to create my own templated helpers, but I got stuck on TextBoxFor
I have tried to find how to create DLL-s on linux using google, but
I tried to create an alias in bash but am not able to do.
I tried to create linq-to-sqlite dbml using DbLinq but in vain. Each time I
I tried to create tables, but it was useless because each begin-end block wrapped
I tried to create a custom .NET attribute with the code below but accidentally
I tried to create a foreign key on one of my tables, referencing a
I tried to create one array of strings in C. Here is the code:
I tried to create an interface ISortableStack using <E extends comparable <E>> but I
I tried to create this by following the video at http://www.asp.net/learn/videos/video-7026.aspx where Joe Stagner

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.