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.