问题描述
我有一个自定义选项卡指示器,使我的标签。不过,我想删除的选项卡下方的底部边框。两个单黑线,和灰度阴影。我甚至不知道是什么原因产生的灰度褪色。这可能是TabWidget,的FrameLayout,还是孩子的LinearLayout中。
I have a custom Tab Indicator to make my tabs. However, I want to remove the bottom border below the tab. Both the single black line, and the greyscale shadow. I'm not even sure what is generating the greyscale fade. It's possibly TabWidget, FrameLayout, or the children's LinearLayout.
有关参考,我试过setStripEnabled(假);
另一个潜在的困难是,我创建TabHost&放大器; TabWidget编程而不使用布局文件
For reference, I've tried setStripEnabled(false);Another potential difficulty is that I'm creating the TabHost & TabWidget programmatically rather than using a layout file.
推荐答案
在我使用的标签,我通常只是通过设置机器人能见度走了隐藏tabwidget标签。
When I use tabs, I normally just hide the tabwidget tag by setting android visibility as gone.
和添加按钮作为标签按钮的
And add buttons to act as the tab buttons like
<?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="0dip"
android:layout_weight="1.0"/>
<FrameLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="64dip">
<Button android:layout_height="fill_parent" android:layout_width="0dip"
android:layout_weight="1.0"
android:background="@drawable/ic_tab_artists"
android:id="@+id/artist_id" android:onClick="tabHandler"/>
<Button android:layout_height="fill_parent" android:layout_width="0dip"
android:layout_weight="1.0"
android:background="@drawable/ic_tab_artists"
android:id="@+id/album_id" android:onClick="tabHandler"/>
<Button android:layout_height="fill_parent" android:layout_width="0dip"
android:layout_weight="1.0"
android:background="@drawable/ic_tab_artists"
android:id="@+id/song_id" android:onClick="tabHandler"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
和我添加一个按钮单击处理程序
and I add a button click handler
public void tabHandler(View target){
artistButton.setSelected(false);
albumButton.setSelected(false);
songButton.setSelected(false);
if(target.getId() == R.id.artist_id){
tabHost.setCurrentTab(0);
artistButton.setSelected(true);
} else if(target.getId() == R.id.album_id){
tabHost.setCurrentTab(1);
albumButton.setSelected(true);
} else if(target.getId() == R.id.song_id){
tabHost.setCurrentTab(2);
songButton.setSelected(true);
}
}
这应该删除所有行和灰度。
This should remove all the lines and grayscale.
这篇关于删除灰度TabWidget边界/边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!