Currently i use TabWidget with 4 tabs on 1 Rows.
Each tab have a text description, not an icon.
I want to insert 1 or 2 Tabs more, but it's not possilbe on the rows because on small screen text description will be too small.
I wonder if a can add antoher tab row (just below the first row) with 1 or 2 tab inside?
My code is:
<TabHost android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:dividerPadding="8dp"
android:scrollbars="horizontal" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="65dp" >
<!-- Tab 1 -->
<LinearLayout
android:id="#+id/tab_alimentation"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
</LinearLayout>
<!-- Tab 2 -->
<LinearLayout
android:id="#+id/tab_lance1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
</LinearLayout>
<!-- Tab 3-->
<LinearLayout
android:id="#+id/linearLayout_tab_resultat"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp">
</LinearLayout>
<!-- Tab 4 -->
<LinearLayout
android:id="#+id/tab_lance2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
</LinearLayout>
</FrameLayout>
</TabHost>
Do you think it's possible,?
thx,
Related
Because the information in each tab may not display depending on screen size, i have added a scrollview. The list view displays the information from the database alright but then it does not spread across the screen. It takes only a small portion of the screen and I can only scroll in that small portion. If i have 2 sets on information I expect to see two rows but I see just one and I can scroll within that to see the second set of information. But when i remove the scroll view my listview displays like it is supposed to but then the other tabs suffer because i cannot scroll to see the other fields.
Below is my main activity:
<TabHost
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tabHost">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="match_parent"></TabWidget>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView"
android:fillViewport="true">
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!--Overview Tab Starts-->
<LinearLayout
android:id="#+id/overviewTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="#+id/displayListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<!--Overview Tab ends-->
<!--Base Data Tab starts-->
<LinearLayout
android:id="#+id/baseDataTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp">
//the needed views go here//
</LinearLayout>
<!--Base Data Tab ends-->
<!--Task Tab starts-->
<LinearLayout
android:id="#+id/taskTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp">
//the needed views go here//
</LinearLayout>
<!--Task Tab ends-->
<!--Survey Tab starts-->
<LinearLayout
android:id="#+id/surveyTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp">
//the needed views go here//
</LinearLayout>
<!--Survey Tab ends-->
</FrameLayout>
</ScrollView>
</LinearLayout>
</TabHost>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabHost"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- Overview Tab Starts -->
<LinearLayout
android:id="#+id/overviewTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/displayListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- Overview Tab ends -->
<!-- Base Data Tab starts -->
<LinearLayout
android:id="#+id/baseDataTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp" >
</LinearLayout>
<!-- Base Data Tab ends -->
<!-- Task Tab starts -->
<LinearLayout
android:id="#+id/taskTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp" >
</LinearLayout>
<!-- Task Tab ends -->
<!-- Survey Tab starts -->
<LinearLayout
android:id="#+id/surveyTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15dp" >
</LinearLayout>
<!-- Survey Tab ends -->
</FrameLayout>
</ScrollView>
</LinearLayout>
You had some problems with your layout_height and width attributes. I changed some of them, this should work ;-)
I want to add icon image as a tab in my android app.
When added, the tab height is equal to icon image height. but width of tab is larger than icon image width. i want tab width also equal to icon image width.
My Application Picture:
My Requirement:
Also, i want to make blue selection strip of tab invisible. i used "android:tabStripEnabled=false" but still it is visible.
layout code:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#drawable/abst"
tools:context=".MainActivity">
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:background="#drawable/header">
</RelativeLayout>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/header">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none"
>
<TabWidget android:id="#android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0sp"
android:tabStripEnabled="false"
android:dividerPadding="0dp"/>
</HorizontalScrollView>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
</FrameLayout>
</LinearLayout>
I wants some hints to make it possible. Thanks.
I have created a TabHost in main activity with 4 tab specs. I have set the background for the Tab host (drawable, png image) and made all activities in the tab specs to be transparent.
For example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- Dummy item to prevent EditText from receiving focus -->
<LinearLayout
android:focusable="true" android:focusableInTouchMode="true"
android:layout_width="0px" android:layout_height="0px"/>
<EditText android:id="#+id/etContactSearch"
android:layout_height="60dip"
android:layout_width="fill_parent"
android:drawableRight="#drawable/search_contact" >
</EditText>
<ListView android:id="#+id/lvContacts"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:cacheColorHint="#00000000"
android:listSelector="#drawable/relative_layout_clickable">
</ListView>
</LinearLayout>
And one of the tab specs has some linear layouts and list activity:
<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:background="#drawable/bck_list">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp" />
</LinearLayout>
</TabHost>
When I start the application from Eclipse, the first time it runs, the background (#drawable/bck_list) is shown perfectly. But if I close the application and run it again, the background is missing (black color is showing instead).
What can be the problem here?
mTabHost.addTab(mTabHost
.newTabSpec("tab_1")
.setIndicator(g(R.string.TList))
.setIndicator(g(R.string.TList),
getResources().getDrawable(R.drawable.lis))
.setContent(new Intent().setClass(this, GList.class)));
I have this layout file in my android application:
<?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">
<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="fill_parent"
android:layout_weight="1">
<TextView
android:id="#+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is a tab" />
<TextView
android:id="#+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is another tab" />
<LinearLayout
android:id="#+id/layoutSearch"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textview4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Search here" />
<EditText
android:id="#+id/editSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</TabHost>
My problem is that LinearLayout android:id="#+id/layoutSearch" shows only one of the elements it contains (the text view, in the code above) If I remove the textview, it shows the EditText.
How do I make it display both (and more) elements?
There's a lot of excess layout there, but it looks like the real issue is that layoutSearch is a vertical LinearLayout with two children, but the first child's height is set to fill_parent, so you naturally never see the second one. Try setting its height to 0px but giving it a layout_weight of 1, and it should expand to take all the available space not taken by the EditText below it.
I am using the following XML for tabs and this displays the tab at the bottom. However the tabs are being overlapped by the list and i cannot access any tab feature. The picture might be able to explain it better.
The list is draw over the tab. I appreciate any suggestions of bringing the tab to the front
XML:
![<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"
>
<View android:layout_width="fill_parent" android:layout_height="0.5dip"
android:background="#000"/>
<TabWidget android:id="#android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginLeft="0dip" android:layout_marginRight="0dip"
android:layout_alignParentBottom="true"
/>
<View android:layout_width="fill_parent" android:layout_height="2dip"
android:background="#696969" />
<View android:layout_width="fill_parent" android:layout_height="2dip"
android:background="#000" />
<FrameLayout android:id="#android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
</RelativeLayout>
</TabHost>][1]
The solution for this is you have to set listview height so it will not overlap the tab at boot, just set fixed size for it.
<Listview
android:layoutheight="some fixed value">
If you are dynamically filling that then use
ln.setLayoutParams(new LayoutParams(width,height));