5

I am using a Tab Host in my Android App. I have the Titlebar hidden.

When I leave the App and resume to it, I have some strange behaviour.

If I resume to a tab using a list activity with listView.setAdapter, the title bar is hidden and the space it takes up is consumed by the App. However, if I resume to any tab without the listView.setAdapter, the Titlebar is hidden, but space which was used by it is left behind.

This is pushes my tabs (which are positioned at the bottom of the screen) off the screen. The space is once again consumed by my app if I then change to any other tab.

I have tried to invalidate most of the obvious Views in my App without and success. Below is my tab_activity xml. many thanks

 <?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">

        <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">
                <FrameLayout android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent" android:layout_height="0dip"
                    android:layout_weight="1" />

                <TabWidget android:id="@android:id/tabs"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"
                    android:layout_weight="0" />
            </LinearLayout>
        </TabHost>

    </LinearLayout>

Here is the Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.tar.projectx" android:versionCode="1"
    android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />

    <application android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
        <activity android:name=".Splash" android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" android:label="@string/app_name" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="SearchActivity" android:label="SearchActivity" android:screenOrientation="portrait"></activity>
        <activity android:name="SearchListActivity" android:label="SearchListActivity" android:screenOrientation="portrait"></activity>
        <activity android:name="ContactActivity" android:label="ContactActivity" android:screenOrientation="portrait"></activity>
    </application>
</manifest>

Interestingly, if I use the code below in the onResume method of my mainActivity which holds the tabhost, once the toast disappears, the view is refreshed and the space at the top is taken up by my app again. Obviously, this isn't much of a fix, but may help someone understand what is happening.

@Override
    protected void onResume() {
        super.onResume();

        Toast.makeText(this, "Welcome Back", Toast.LENGTH_LONG).show();
    } 
  • I have exactly the same problem. Did you found a solution? Has anyone a solution? – Inna Jan 16 '12 at 13:08
  • What do you mean by "resuming to the activity using a list activity with listView.setAdapter"? – a.ch. Jan 17 '12 at 15:25
  • Hi Inna. I have to admit. After a good ear bashing from a "usability consultant" I realised that I should never hide the titlebar, as the user has a right to see their signal, battery, notifications e.t.c. Not much help if it is an absolute priory. Apologies. However, if you find an answer, it would be interesting to know. –  Jan 17 '12 at 22:14
  • a.ch. To answer your question. If I left the app while an Activity with a listview (being populated with setAdapter) was displayed, then if I went back to the app (resumed the activity) the problem would not appear. cheers –  Jan 17 '12 at 22:16

2 Answers2

0

I would try to manually call requestLayout() and/or requestWindowFeature(Window.FEATURE_NO_TITLE) in my onResume()... furthermore, try seeing when is the onMeasure() method called for your view. This is just out of the top of my head ;) hope it helps. Cheers!

Stamoulohta
  • 649
  • 1
  • 7
  • 21
0

Pleas set main Tab bar activity theme as android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Gangineni
  • 1
  • 1