TabLayout内的工具栏 [英] TabLayout inside Toolbar
问题描述
我要达到一定的外观与新的设计支持库,我不能再看到一个奇怪的问题。
I want to achieve a certain look with the new Design Support Library and I can't stop seeing a weird bug.
下面的 与期望输出的截屏 (不与DSL完成) 和 我开始使用DSL的输出中
Here's the screencast with the desired output (not done with DSL) And the ouput I get using DSL.
工具栏+标签是一个viewpager活动,而recyclerView是viewpager中的片段内(实际上是适配器,但你明白我的意思)
The toolbar+tabs is in an activity with a viewpager, and the recyclerView is inside a fragment within the viewpager (the adapter actually, but you get my point)
$ C $下活动:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@color/white"
app:tabTextColor="@color/selected_text"
app:tabSelectedTextColor="@color/white"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/main_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.SupportFloatingActionsMenu
...>
/* Code for a fancy fab w/ menu */
</android.support.design.widget.SupportFloatingActionsMenu>
</android.support.design.widget.CoordinatorLayout>
有关含recyclerView片段:
For the fragment containing the recyclerView :
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.insa.burnd.view.MainActivity.NewsfeedFragment"
android:id="@+id/fragment_newsfeed">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
在Java code是pretty的标准,我兵的viewpager的标签...等。
The java code is pretty standard, I bing the viewpager to the tabs... etc.
感谢您在您的帮助:)!
Thank you in advance for your help :) !
推荐答案
这和许多其他错误修复固定在的版本22.2.1 设计库中。请确保您的 build.gradle
文件引用的最新版本。
This and many other bug fixes were fixed in version 22.2.1 of the Design Library. Please make sure your build.gradle
file references the newest version.
这篇关于TabLayout内的工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!