How to delete 2 point in bottom of tabhost
Please see below image to get more detail.
Thanks so much.
This is XML, I'm using default tabhost and i don't know why they appear
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginBottom="50dp">
<TabHost android:id="#android:id/tabhost"
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_gravity="top"
android:layout_marginLeft="-4dp"
android:layout_marginRight="-4dp"
android:layout_marginTop="37dp"
android:layout_weight="1" >
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
style="#color/white"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
</FrameLayout>
You're going to need to post the XML/Code you used to create this.
Related
I have a Tabhost in my app which have 5 tabs in it. I set a background image on my tabhost by putting android:background = "#drawable/background" in my xml file, but unfortunately the whole ui becomes laggy. How can I optimize the image in order to eliminate the lag in my UI? Please help me with this one.
<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/background">
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FCAFA6"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height= "52dp"
android:background="#drawable/header" />
<TextView
android:id="#+id/tabTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
android:text="Home"
android:textColor="#FFFFFF" />
</LinearLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" >
</TabWidget>
</LinearLayout>
</TabHost>
You have to make various device size background and put on respective folder for more check this :Android background image size in pixel
I'm trying to create a tab-bar like the one shown in the image below ( i.e. a tab-bar with some images on the left ) .
The white part are two images while the black part are the tab-labels
Can anyone guide me in doing the same ?
Using actionBar.addTab(actionBar.newTab()
//.setText(mSectionsPagerAdapter.getPageTitle(i))
.setCustomView(view)
.setTabListener(this));
Here, you customize your layout and parse it into view
See [How to set a custom View in ActionBar's navigation tabs and make the tabs adapt to its height?
I managed to get a workaround without using action bar . Just some XML code tweaking , and I was good to go . Here's what I did :
<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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/tab_bg" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/options"
android:layout_gravity="center"
android:layout_marginLeft="10dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/img"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignLeft="#+id/linear"
android:layout_below="#+id/linear">
</FrameLayout>
</RelativeLayout>
</TabHost>
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 made one Layout in which I want to set the another layout from the existing xml file. Is this possible?
See below code:
<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">
<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">
<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" />
<TextView
android:id="#+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is a third tab" />
</FrameLayout>
</LinearLayout>
Now I want to set the Layout in the frameLayout`
how it this possible?
Thanks.
Just create another activity with your second layout and then start the second activity with startActivity().
You didn't provide any code, but if you have 2 layouts in xml and the first one should include the second one, use the include-tag.
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));