Implement material tabs and androidtabs on the android 5.0 toolbar

Source: Internet
Author: User

Implement material tabs and androidtabs on the android 5.0 toolbar

In android5.0, how can we achieve a tab effect similar to that in play store? (Rolling hiding, suitable padding), I tried SlidingTabs and some other lib libraries, and they are basically out of date ..
 
For details, in versions earlier than Android 5, I often use actionBar. setNavigationMode (ActionBar. NAVIGATION_MODE_TABS) for api20. But in Android, the entire ActionBar is replaced by the ToolBar.
.
How can we correctly use Material Design to make effects similar to google paly store? In android 5, how does one hide tabs during scrolling?

Solution

Their layout is basically the same as that of 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>


Address: http://www.itmmd.com/201411/209.html
This article is organized and published by Meng IT personnel. The reprinted article must indicate the source.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.