i have tried to remove spaces from bottom of tabs. screen shot of space
Here is my xml code.
I want to remove that space below green color of my tab.
enter code here
<LinearLayout
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"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:divider="@null"
android:gravity="bottom"
android:showDividers="none"
android:tabStripEnabled="false" />
</LinearLayout>
i have search so much but not getting proper solution.
I want to remove that space below green color of my tab.
Suggestions are appreciated.
尝试android:tabStripEnabled="false"
Referred from SO Post
Try these modifications. This code is taken from a fragment that has tabs.
Here is the code that creates the tab indicator view.
View indicator = LayoutInflater.from(getActivity()).inflate(R.layout.tab,(ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
TabSpec tabSpec = mTabHost.newTabSpec(tag);
tabSpec.setIndicator(indicator);
tabSpec.setContent(tabContentId);
Your tab indicator view would probably like similar to this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/tabselector"
android:padding="5dp" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/tab1icon"/>
</LinearLayout>
Now the important part here is the android:background="@drawable/tabselector"
in the LinearLayout. Mine looks like this.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected_light" />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_selected_light" />
<!-- Focused states -->
<item
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_focused_light" />
<!-- Pressed state -->
<item
android:state_pressed="true"
android:drawable="@drawable/tab_pressed_light" />
</selector>
This tabselector.xml is where you will swap @drawable/tab_pressed_light
with your @drawable/tab_button_active
and @drawable/tab_unselected_light
with @drawable/tab_button_inactive
OR
You can remove the bottom strip of tabs and divider between tabs by using following statement.
TabHost t;
t.getTabWidget().setStripEnabled(false);
t.getTabWidget().setDividerDrawable(R.drawable.ic_launcher);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.