android 5.0 toolbar 上實現 material tabs,androidtabs

來源:互聯網
上載者:User

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人 整理髮布,轉載須標明出處。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.