使用设计支持库时,Home键未显示 [英] Home button not shown when using the design support library

本文介绍了使用设计支持库时,Home键未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我显示与home键可见的工具栏。在某些屏幕这可以作为一个向上按钮,在别人没有。

In my app, I'm displaying a Toolbar with the home button visible. In some screens this works as an up button, in others not.

这工作得很好。

问题是,导入设计支持库时,home键是不是在工具栏上显示。 这种情况只是通过导入吧,code不是单行线改变。

Problem is that when importing the design support library, the home button is not shown in the toolbar. This happens just by importing it, not a single line of code changed.

我将其导入的摇篮与

compile 'com.android.support:design:22.2.0'

我需要改变的东西在code为设计库不使家庭按钮消失?这是在设计库另一个bug?

Do I need to change something in code for the design library not to make the home button disappear? Is this another bug in the design library?

请注意,我还使用了支持的lib这样的:

Note, I'm also using the support lib like:

compile 'com.android.support:appcompat-v7:22.2.0'

另外,我这是怎么吹的工具栏

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!-- toolbar -->
    <FrameLayout
        android:id="@+id/toolbarContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">

        <include layout="@layout/include_toolbar" />

    </FrameLayout>

    [....]
</RelativeLayout>

这是我在一个设置了home键片段

This is how I set up the home button in one Fragment.

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup         
          [....]
          final Toolbar toolbar = (Toolbar)           
          view.findViewById(R.id.toolBar);
          toolbar.setTitle(R.string.foo);
          toolbar.setNavigationIcon(R.drawable.bar);
          [....]
    }

至于说,这些作品完全罚款,直到我刚刚导入设计 LIB的摇篮。

感谢你。

推荐答案

我personnaly获得工具栏然后将其设置为动作条键,使用常规的方法,它为我工作。

I personnaly get the Toolbar then set it as ActionBar and use the regular methods and it works for me.

希望它可以帮助你:

final Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolBar);
toolbar.setTitle(R.string.foo);
toolbar.setNavigationIcon(R.drawable.bar);
setSupportActionBar(toolbar);

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

这篇关于使用设计支持库时,Home键未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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