下面是我想要删除的内容:
如何替换显示当前显示的选项卡的指示器以及横跨整个选项卡小部件的蓝线?
要指定:我只想指出选择了哪个选项卡:
如果选项卡是SELECTED
编辑:将tabStripEnabled设置为false不起作用。向其添加样式并将"@android: style /Widget.Holo.ActionBar“作为其父对象也是不可能的,因为im的目标是API7,而ActionBar是在API11中实现的。
发布于 2013-03-07 08:52:00
如果android:tabStripEnabled="false"
不工作,那么我也假设调用setStripEnabled(boolean stripEnabled)
也不会有任何效果。如果所有这些都是真的,那么您的问题可能不在TabWidget。
我建议你看看你的标签指示器。尝试这些修改。这段代码取自一个带有制表符的片段。
下面是创建选项卡指示器视图的代码。
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);
您的tab indicator视图可能类似于此。
<?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>
现在这里最重要的部分是LinearLayout中的android:background="@drawable/tabselector"
。我的是这样的。
<?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>
在这个tabselector.xml中,您可以将@drawable/tab_pressed_light
与@drawable/tab_button_active
交换,将@drawable/tab_unselected_light
与@drawable/tab_button_inactive
交换
请务必检查tabselector.xml中的所有可绘制部分是否没有底部的蓝色条带。当我看着你的图像时,我可以看到沿着那个条带的小5px的间隙,这就是为什么我认为这个条带不是来自你的TabWidget。希望这能有所帮助。
发布于 2015-11-17 00:04:48
我还有另一个技巧。
TabLayout tabLayout = (TabLayout) fragmentView.findViewById(R.id.tabs);
tabLayout.setSelectedTabIndicatorHeight(0);
这基本上与Eleojasmil的想法相同。
发布于 2016-01-28 22:06:34
下面这行app:tabIndicatorHeight="0dp"
为我解决了xml中的问题。
<android.support.design.widget.TabLayout
android:id="@+id/view_bottom_tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorHeight="0dp" //this line
app:tabGravity="fill"
app:tabMode="fixed" />
https://stackoverflow.com/questions/14672302
复制相似问题