android 5.0 toolbar 上實現 material tabs,androidtabs
android5.0 中如何才能實作類別似play store中的tab效果?(滾動式隱藏,合適的間距),我嘗試過 SlidingTabs 和其他的一些lib庫,他們基本上都超期了..
關於一些細節方面,android5之前的版本中,api20一下,我經常使用 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ,但是在android5.0中,整個ActionBar 都被ToolBar替換了
.
如何才能正確的使用 Material Design 做出類似 google paly store的效果? android 5中如何讓tabs在滾動的時候隱藏?
處理方法
他們的layout如下,基本上是這樣的,達不到和 play store完美一樣的程式
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" app:theme="@style/ThemeOverlay.AppCompat.ActionBar"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" /> <widget.SlidingTabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> </android.support.v7.widget.Toolbar> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"> <TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <android.support.v4.view.ViewPager android:id="@+id/ViewPager" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout></LinearLayout>
原文地址:http://www.itmmd.com/201411/209.html
該文章由 萌萌的IT人 整理髮布,轉載須標明出處。