在TabLayout设计支持库中看不到选项卡指示器 [英] Unable to see Tab Indicator in TabLayout design support library
问题描述
我正在使用Material Design库,并使用CoordinatorLayout
,AppBarLayout,RecyclerView
和TabLayout
创建布局.
I am using Material design library and creating layout using CoordinatorLayout
,AppBarLayout ,RecyclerView
and TabLayout
.
我的问题是我无法在Tablayout
中看到Tab指示器.下面是我在AppCompactActivity
中使用的xml文件.
My issue is i am unable to see Tab indicator in Tablayout
.Below is my xml file that i am using in AppCompactActivity
.
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coodinate_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/btn_next_screen">
<android.support.v7.widget.RecyclerView
android:id="@+id/list_recycle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="30dp"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.design.widget.AppBarLayout
android:id="@+id/abar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@color/tab_bg"
app:tabIndicatorColor="@color/tab_indicator"
app:tabIndicatorHeight="5dp"
app:tabMode="fixed"
></android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
app:layout_anchor="@+id/list_recycle"
app:layout_anchorGravity="bottom|right"
android:id="@+id/floatin_ab_home"
app:fabSize="mini"
android:src="@drawable/ic_content_add"
/>
</android.support.design.widget.CoordinatorLayout>
下面是不显示Tab指示符的屏幕,因此任何人都可以知道我所缺少的内容.
Below is screen which don't showing Tab indicator so can any one known what i am missing .
推荐答案
我认为这是设计支持库中的错误.那 当您同时应用两个属性时
I think it's bug on Design Support library. that When You apply both property at the same time
app:tabBackground="@color/tab_bg"
app:tabIndicatorColor="@color/tab_indicator"
背景色 与 标签指示符重叠.这就是为什么标签指示符不可见的原因.
the background color overlap the tab indicator. that's why the tab indicator is not visible.
如果删除tabBackground颜色属性,则可以看到指示器.
If you remove tabBackground color property then you can see the indicator.
[2015年6月25日更新]
正如我所说的这是设计支持库中的错误.我将其报告给android bug源.这是 https://code.google.com/p/android /issues/detail?id = 176540 .
As I said it's bug on Design Support library. I reported it to android bug source. here is the refrence https://code.google.com/p/android/issues/detail?id=176540.
因此,此问题的状态为 FutureRelease ,因此已修复错误.它将在将来的库中提供.
So status for this is issue is FutureRelease so bug is fixed. And it will come in future library.
[更新20-07-2015]
该错误已在22.2.1版中修复并发布.您也可以在上面的链接上对其进行检查.
The bug is fixed and Released in v 22.2.1. you can also check it on above link.
这篇关于在TabLayout设计支持库中看不到选项卡指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!