我在stackoverflow
中嘗試了此問題的所有解決方案,但沒有任何幫助。所有的 首先,我要實現的佈局像這樣的或類似的是:如何在摺疊工具欄佈局下添加viewpager和tablayout
並根據stackoverflow
像this 我能夠實現這個佈局一些問題:
與該XML文件:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="256dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/bgheader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/aks"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/MyToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_collapseMode="pin" />
<com.majid.whiteboard.utils.CustomTabLayout
android:id="@+id/tab_layout_detail_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:paddingEnd="20dp"
app:paddingStart="20dp"
app:tabGravity="fill"
app:tabIndicatorColor="@color/silver"
app:tabIndicatorHeight="4dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/grid_text_color"
app:tabTextColor="@color/grid_text_color" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager_detail_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
每一件事情是確定的,但現在我有兩個問題:
1.Tablayout轉到屏幕的頂部,但我要崩潰的工具欄下添加此
2.我只能摺疊工具欄只在摺疊區域(意味着只在圖片和頂部),它不能在屏幕上的其他地方工作。
HTTP後:// stackoverfl ow.com/a/36031051/5275436我有同樣的問題。我希望它適合你。 –
我可以知道,你爲什麼使用庫來製作TabLayout?@majid –
@GovindaP我嘗試了你的sulution:但是我遇到了問題,它不能在視圖傳呼區域工作 – majid