与工具栏的Android 5.0的材料标签 [英] Android 5.0 material tabs with toolbar
问题描述
我怎样才能实现播放存储像标签(隐藏在滚动,适当的利润,瘦指标)?我试过SlidingTabs和其他一些图书馆,但他们都已经过时。
How can I achieve play store like tabs (Hide on scroll, proper margins, thin indicator)? I've tried SlidingTabs and some other libraries, but they all are outdated.
在更多详细信息,当我开发的API 20和以下(之前的Android 5.0),我习惯叫 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
?
现在,采用Android 5.0,整个动作条正在取代工具栏。
In more details, when I was developing for APIs 20 and less (before Android 5.0), I used to call actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
?
Now with Android 5.0, the whole ActionBar is being replaced by ToolBar.
什么是正确的方式,使用材料设计标签,使用工具栏?我怎样才能让标签隐藏卷轴?
What is the right way to use Tabs in Material Design, using ToolBar? How can I make the Tabs hide on scroll?
谢谢!
截图:
推荐答案
有布局这一点。它不完全一样的新戏商店,但pretty的接近。只是无法摆脱工具栏的保证金。
There's layout for this. It doesn't look exactly like new play store, but pretty close. Just can't get rid of toolbar margin.
<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>
这篇关于与工具栏的Android 5.0的材料标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!