10
我想用新的設計支持庫實現一定的外觀,並且我無法停止看到一個奇怪的錯誤。工具欄內的TabLayout
這裏的the screencast with the desired output(不與DSL完成) 而the ouput I get using DSL。
工具欄+標籤是與viewpager的活性,recyclerView是viewpager內的片段內(實際上是適配器,但你明白我的意思)
代碼的活動:
<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片段:
<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代碼是非常標準的,我的兵viewpager到接頭...等
非常感謝您的幫助:)!
當您從片段佈局中刪除'CoordinatorLayout'和'SwipeRefreshLayout'時,會發生什麼變化嗎? – ianhanniballake
我得到相同的故障。 – Mehdi
您可以使用新發布的[版本22.2.1](https://plus.google.com/+AndroidDevelopers/posts/XTtNCPviwpj)再次嘗試嗎? – ianhanniballake