android - appcompat 21 标志作为后退按钮

标签 android android-actionbar android-appcompat

更新sdk到21版本后logo不显示。我使用以下代码显示 Logo :

actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setIcon(R.drawable.ic_launcher);

代码如下: http://i.stack.imgur.com/fAWIx.png

enter image description here

这段代码:

actionBar.setDisplayShowHomeEnabled(true);
actionBar.setIcon(R.drawable.ic_launcher);

外观: http://i.stack.imgur.com/hkYqa.png

enter image description here

这段代码:

actionBar.setDisplayHomeAsUpEnabled(true);

外观: http://i.stack.imgur.com/Ssw2A.png

enter image description here

我的 Logo 没有显示为后退按钮。

如何像这里一样制作旧样式? http://i.stack.imgur.com/BKOz4.png

注意:抱歉,我没有注意到类似的问题。 =(

最佳答案

根据 Toolbar documentation :

  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

但是,如果您想要一个应用程序图标,setLogo()确实是正确的方法。

关于android - appcompat 21 标志作为后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26642378/

相关文章:

android - 将 android-support-v7-appcompat 添加到 Eclipse 上的项目时,项目选择 Pane 为空白

java - 媒体扫描仪正在扫描,但不刷新 (Android)

android - 如何实现像谷歌地图这样的操作栏

android - 系统栏隐藏菜单项

Android:标题栏和ActionBar有什么区别

Android 如何获取支持操作栏的 AppCompat.Translucent 类型主题?

android - 为什么每当我创建新项目时 Eclipse 会自动添加 appcompat v7 库支持?

android - 是否可以将 AppCompat 21 中的 SearchView 与工具栏左对齐?

Android 滑动 View ?

android - ionic 3 : Could not find support-compat. aar (com.android.support :support-compat:26. 1.0