Search code examples
androidtextviewandroid-tabhosttablerowinvisible

How to stack diffrent layout objects, over each other?


Hello Guys and probably some Girls, is it possible to stack Layout Objects. So that one Object is over the other one? My Problem is this, i've got a tabhost and under the tabhost i've got a tablerow with a textview in it.

I made the tabhost tabs invisible, but it hiddes my tablrow with the textview in it,how can i bring it infront?

Here is the Layout.xml

<?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"
        android:weightSum="1">
    <RelativeLayout
       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="fill_parent"
           android:layout_weight="1" />
       <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_alignBottom = "@android:id/tabcontent" 
           android:visibility="invisible"/>

       <TableRow 
            android:id="@+id/ADFilterOverview" 
            android:layout_height="wrap_content" 
            android:onClick="onClickADConfig" 
            android:layout_alignParentBottom="true" 
            android:layout_alignParentLeft="true" 
            android:layout_alignTop="@android:id/tabs" 
            android:layout_width="match_parent">

           <TextView 
                android:text="@string/newadfilter" 
                style="@style/NormalFont" 
                android:layout_gravity="bottom|left">
           </TextView>
       </TableRow>
    </RelativeLayout>
</TabHost>

Thx in Advance

Best Regards safari

Some more information, for better understanding:

Afterwards my code of my Activity looks something like this:

package de.retowaelchli.filterit;

    import android.app.TabActivity;
    import android.os.Bundle;
    import android.widget.TabHost;
    import android.content.Intent;

    public class StatsActivity extends TabActivity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.stats);
            TabHost tabHost = getTabHost();       

            tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("whatever").setContent(new Intent(this, SFilterStatsActivity.class)));
            tabHost.setCurrentTab(1);

        }

    /** Verweise auf die anderen Seiten **/
public void onClickADConfig(View view){
    final Intent i = new Intent(this, ADFilterConfigActivity.class);
    startActivity(i); }


    }

The linked class from my Tabhost looks for example like this:

    package de.retowaelchli.filterit;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;


public class ADFilterStatsActivity extends ListActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mListContent));   
    }  

    private static String[] mListContent={"Item 1", "Item 2", "Item 3","Item 1", "Item 2", "Item 3","Item 1", "Item 2", "Item 3","Item 1", "Item 2", "Item 3"};
} 

So you see, i got a TabHost with one tab in it, which is filled from my ListActivity, the tabhost should be hidden (invisible), over this hidden tab should be the tablerow visible. So i can click it to get to my other class. I hope this helps you guys...

FOUND A SOLUTION THX Egon

And here is the solution

   <?xml version="1.0" encoding="utf-8"?>


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
     >



       <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">
       <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_alignBottom = "@android:id/tabcontent" 
           android:visibility="invisible"/>
       <TableRow android:layout_height="wrap_content" android:id="@+id/ADFilterOverview" android:layout_width="match_parent" android:onClick="onClickADConfig" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true">
           <TextView android:layout_gravity="bottom|left" android:text="@string/newadfilter" style="@style/NormalFont"></TextView>
       </TableRow>
       </RelativeLayout>
      </TabHost>


  </FrameLayout>

Solution

  • If you make Parentview invisible then its childview also automatically make invisible. In this scenario you have to define other layout for your new tab.

    If this is not correct, please make edit in, or suggest me. Thanx

    EDIT: on your xml code I think tabhost is a parentview and tablerow , textview are childview of it.