【发布时间】:2011-08-01 19:04:51
【问题描述】:
我有一个自定义标签指示器来制作我的标签。但是,我想删除选项卡下方的底部边框。单条黑线和灰度阴影。我什至不确定是什么产生了灰度渐变。可能是 TabWidget、FrameLayout 或孩子的 LinearLayout。
作为参考,我试过 setStripEnabled(false); 另一个潜在的困难是我正在以编程方式创建 TabHost 和 TabWidget,而不是使用布局文件。
【问题讨论】:
我有一个自定义标签指示器来制作我的标签。但是,我想删除选项卡下方的底部边框。单条黑线和灰度阴影。我什至不确定是什么产生了灰度渐变。可能是 TabWidget、FrameLayout 或孩子的 LinearLayout。
作为参考,我试过 setStripEnabled(false); 另一个潜在的困难是我正在以编程方式创建 TabHost 和 TabWidget,而不是使用布局文件。
【问题讨论】:
当我使用标签时,我通常只是通过将 android 可见性设置为消失来隐藏 tabwidget 标签。
并添加按钮以充当标签按钮,例如
<?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>
我添加了一个按钮点击处理程序
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);
}
}
这应该删除所有的线条和灰度。
【讨论】: