Android tabwidget tabs width fix - android

I've followed the answer of rekaszero in Android remove space between tabs in tabwidget but now i need to set the tabs fit the screen automatically (in this mini-tut they are too big and they are off the screen) and also need to remove the text because the tabs should have only the icon to occupy the entire tab and not text. I can set their width in the main.class but i dont want to set their width, but they to fit auto.
Can someone help me out?
thanks

Ok. I figured out the big tabs width with the replacement with this code on main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp" >
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
Now i'll try to remove the text from it. If you already know how help me out. thanks

Related

FragmentTabHost add a persistent Button to a scrollable TabWidget

I want to add a Button at the right end of my TabWidget.
The TabWidget is inside a HorizontalScrollView (added in code)
but the Button shall not scroll together with the tabs,
but stay persistently right of the tab bar.
I'm not sure if I can customize the TabWidget that way, so another idea would be
to place such a Button just besides the TabWidget.
I tried this with the follwing Layout, but the TextView does not appear.
So the question for me is, is it generally doable, or do I need a different approach ?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/content_tabhost"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/tab_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEARCH HERE"/>
</LinearLayout>
<FrameLayout
android:id="#+id/content_body"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>

Make android tab width equal to icon image width

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.

Android Actionbar Tabs on bottom of screen

I agree before-hand with anyone who wants to make the argument that tabs should be at the top of the screen, but I can't control the requirements for my app :) . I have to build an app with tabs at the bottom of the screen. I'm using SDK 14 and Actionbars. Is this even possible? I have already built a layout with the tabs at the bottom, but when I add the tabs to the ActionBar, they are automatically rendered at the top of the screen.
Any ideas would be really appreciated, and thank you all for taking the time to read this post.
You can use Tabhost for requirement,and inside tab.xml you can write below code . This will work fine .
<?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">
<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:tabStripEnabled="false"
android:layout_alignBottom="#android:id/tabcontent"
android:background="#000000" />
</RelativeLayout>
</TabHost>

Strange Redraw behavior in Android

I am using android support package v4 and the following layout to show up a scrollable tabbar + corresponding slideable contentviews:
<?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">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:gravity="center_vertical"
android:layout_height="wrap_content">
<HorizontalScrollView
android:layout_width="wrap_content"
android:id="#+id/horizontalScrollView"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget
android:id="#android:id/tabs"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</HorizontalScrollView>
</LinearLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>
It works well lets say 90% but 10% it just don't redraw the ui. Even the invalidate of the elements doesn't solve the problem.
Now the strangest part: After locking and relocking the phone, everything shows up like expected and works like a charm.
For example:
I add a new tab + fragment.
- Tab + Fragment are added, all methods on them are called, but the UI is just black. lock+unlock = everything is okay again.
Handling userinput on fragment. (See pic)
Notice:
I already tested the invalidation of all elements, it doesn't work.
What else can I do to solve this problems?
Thanks in advance
There was a memoryleak on the tabhost.

Layout with ListView and TabHost on Android

I want make a layout like this:
The thing with the action bar is fine, I made it work. But the left list with the images is displayed over the whole display when I create a ListView, so you can't see the TabHost on the right side. So how can I make a ListView on the left and a TabHost right, so that the list is 20% of the display and the tab 80%?
So that you can select an image in the list and do something with it in the tabs. It's for tablets and I work with the Honeycomb 3.0 API.
My Layout is like this:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/id_list_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="#+id/tabhost"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
I recommend you to make this screen using Fragments, it's the best and the correct way to achieve what you want
Keep layout weight property for both vertical Linear Layouts as 0.2 and 0.8 respectively and keep layout width equal to 0 pixels for both vertical Linear Layouts.

Categories

Resources