[英]Toggle the Navigation Drawer via the stock Action Bar title with highlight
I'm trying to mimic the Google Play Store application ActionBar: when you click on the title of the application, the title itself is highlighted (normally with a blue background in JB) and the Navigation Drawer opens /closes. 我正在尝试模仿Google Play商店应用程序的ActionBar: 单击应用程序的标题时 , 标题本身会突出显示 (通常在JB中带有蓝色背景) ,并且导航抽屉会打开 /关闭。
I'm using the Navigation-Drawer sample application available on Google Developers website ( link ) and it doesn't do the same. 我正在使用Google Developers网站( 链接 )上提供的Navigation-Drawer示例应用程序,它没有做到这一点。 There is no blue background when you touch the title and also the "click zone" on the title text is only about 3-4 characters of lenght as width.
触摸标题时没有蓝色背景,并且标题文本上的“单击区域”仅为宽度的大约3-4个字符。 On the Play Store or Gmail applications you can touch even the end of the string and the Navigation Drawer will open.
在Play商店或Gmail应用程序上,您甚至可以触摸字符串的结尾,导航抽屉将打开。 See this screenshot for reference:
请参阅以下屏幕截图以供参考:
So, I'm looking for tips or even links to source code of other Android applications that have this feature and also: 因此,我正在寻找技巧或什至指向具有此功能的其他Android应用程序的源代码的链接,以及:
Thanks! 谢谢!
By default, the title is included in the touch target for the drawer on Android 4.3 and Android 4.4 devices (unlike previous versions of Android where the title was not included) so you shouldn't have to do anything to get consistent touch targets. 默认情况下,标题包含在Android 4.3和Android 4.4设备上的抽屉的触摸目标中(与不包含标题的Android早期版本不同),因此您无需执行任何操作即可获得一致的触摸目标。
Note that in Android 5.0 and Material Design, the navigation button is much larger (taking the place of the app icon) and the title is not included in the touch target. 请注意,在Android 5.0和Material Design中,导航按钮要大得多(代替应用程序图标的位置),并且标题不包括在触摸目标中。 Updating to AppCompat v21 will give you this new functionality and be consistent with Google apps across all API versions (although note that not all Google apps have fully followed the guidelines as of yet - a work in progress as they all move to using AppCompat)
更新至AppCompat v21将为您提供此新功能,并与所有API版本中的Google应用程序保持一致(尽管请注意,到目前为止,并非所有Google应用程序都已完全遵循指南-正在进行中,因为它们都在使用AppCompat。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.