在棒棒糖Play商店抽屉指标 [英] Drawer indicator in lollipop play store

查看:543
本文介绍了在棒棒糖Play商店抽屉指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的Nexus 7的Andr​​oid 5.0 preVIEW构建。

I am using a Nexus 7 with the Android 5.0 preview build.

在此页 <一href="http://developer.android.com/tools/support-library/index.html">http://developer.android.com/tools/support-library/index.html

我看

有关V7 appcompat库的变化:更新时间: ActionBarDrawerToggle ,其中   包含菜单对箭头动画

Changes for v7 appcompat library: Updated ActionBarDrawerToggle, which contains the menu-to-arrow animation

请问这是什么的谷歌Play应用用途?我是不是过度解读这一说法?需要什么改变来获得这一行为 - 我无法找到它的API文档中

Is this what the Google Play app uses? Am I reading too much into this statement? What do I need to change to get this behavior - I can't find it in the API documentation.

推荐答案

我已经张贴在这里的示例应用程序,使用新的工具栏类,并ActionBarToggle提供的Play商店式的动画图标的动作条:

I've posted a sample app here that uses the new Toolbar class and ActionBarToggle to provide an ActionBar with the Play Store style animating icon:

<一个href="https://github.com/03lafaye/LollipopDrawerToggle">https://github.com/03lafaye/LollipopDrawerToggle

在无V7支持分支使用了一个框架活动和工具栏的ActionBarToggle。主分支使用V7工具栏和ActionBarActivity。

The no-v7-support branch uses the ActionBarToggle with a framework Activity and Toolbar. The master branch uses the v7 Toolbar and an ActionBarActivity.

的设置为不使用ActionBarActivity看起来是这样的:

The setup for not using an ActionBarActivity looks like this:

package com.plafayette.lollipop;

import android.app.Activity;
import android.support.v4.widget.DrawerLayout;
import android.os.Bundle;
import android.support.v7.app.ActionBarDrawerToggle;
import android.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

public class ToolbarActivity extends Activity {
    private ActionBarDrawerToggle toggle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toolbar);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setActionBar(toolbar);

        DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        toggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open, R.string.close);
        toggle.setDrawerIndicatorEnabled(true);
        drawerLayout.setDrawerListener(toggle);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        toggle.syncState();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.toolbar, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (toggle.onOptionsItemSelected(item))
            return true;

        int id = item.getItemId();
        return id == R.id.action_settings || super.onOptionsItemSelected(item);
    }
}

请注意,您必须禁用窗口动作条和标题栏在你的主题像这样:

Note that you have to disable the window actionbar and title bar in your theme like so:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

我想象中的样品code最新的V7 appcompat库将被释放很快使这个职位已经过时了。

I imagine the sample code for the latest v7 appcompat library will be released soon enough making this post obsolete.

克里斯人可从广场发表了图标动画的另一种反向移植。在code是在GitHub上的位置:<一href="https://github.com/ChrisRenke/DrawerArrowDrawable">https://github.com/ChrisRenke/DrawerArrowDrawable他写了一篇关于它的博客 http://chrisrenke.com/drawerarrowdrawable

Chris Renke from Square published an alternate backport of the up icon animation. The code is on GitHub here: https://github.com/ChrisRenke/DrawerArrowDrawable and he wrote a blog about it at http://chrisrenke.com/drawerarrowdrawable.

这篇关于在棒棒糖Play商店抽屉指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆