openDrawerContentDescRes和closeDrawerContentDescRes是什么鬼
DrawerLayout可以配合一个ActionBarDrawerToggle,其构造方法如下
ActionBarDrawerToggle (Activity activity,
DrawerLayout drawerLayout,
int openDrawerContentDescRes,
int closeDrawerContentDescRes)
ActionBarDrawerToggle (Activity activity,
DrawerLayout drawerLayout,
Toolbar toolbar,
int openDrawerContentDescRes,
int closeDrawerContentDescRes)
参数说明
activity Activity: The Activity hosting the drawer.
drawerLayout DrawerLayout: The DrawerLayout to link to the given Activity's ActionBar
toolbar Toolbar: The toolbar to use if you have an independent Toolbar.
openDrawerContentDescRes int: A String resource to describe the "open drawer" action for accessibility
closeDrawerContentDescRes int: A String resource to describe the "close drawer" action for accessibility
最后一直没搞明白是什么,也没见它发挥过作用,搜了很多文章,好像大家都飘过这两个参数了,搜了好久终于明白了,其重点在于
accessibility!accessibility!accessibility!
官网对accessibility的解释
Many Android users have different abilities that require them to interact with their Android devices in different ways. These include users who have visual, physical or age-related limitations that prevent them from fully seeing or using a touchscreen, and users with hearing loss who may not be able to perceive audible information and alerts.
Android provides accessibility features and services for helping these users navigate their devices more easily, including text-to-speech, haptic feedback, gesture navigation, trackball and directional-pad navigation. Android application developers can take advantage of these services to make their applications more accessible.
Android developers can also build their own accessibility services, which can provide enhanced usability features such as audio prompting, physical feedback, and alternative navigation modes. Accessibility services can provide these enhancements for all applications, a set of applications or just a single app.
简单来说就是openDrawerContentDescRes与closeDrawerContentDescRes的内容不会显示在屏幕上,但是可以通过accessibility services转换成语音为那些视力不好的人服务。就是如此!