大佬教程收集整理的这篇文章主要介绍了Android工具栏中是否可以同时具有后退和菜单按钮?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<android.support.v7.widget.Toolbar xmlns:android="http://scheR_313_11845@as.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:minHeight="?attr/actionBarSize"> <ImageView android:id="@+id/BACkButton" android:BACkground="@drawable/BACk_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/homeButton" android:BACkground="@drawable/menu_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </android.support.v7.widget.Toolbar>
然后设置侦听器以执行诸如openDrawer之类的任务并转到上一屏幕.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); ImageView homeButton = (ImageView) toolbar.findViewById(R.id.homeButton); homeButton.setOnClickListener(new View.onClickListener() { @Override public void onClick(View view) { drawerLayout.openDrawer(GravityCompat.START); } });
以上是大佬教程为你收集整理的Android工具栏中是否可以同时具有后退和菜单按钮?全部内容,希望文章能够帮你解决Android工具栏中是否可以同时具有后退和菜单按钮?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。