http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0303/2522.html(转载)

Toolbar介绍

ActionBar由于其设计的原因,被限定只能位于活动的顶部。从而不能实现一些Material Design的效果,因此官方现在已经不再建议使用Actionbar了。Toolbar的强大之处在于,它不仅继承了Actionbar的所有功能,而且灵活性很高,可以配合其他控件来完成一些MaterialDesign的效果。

DrawerLayout介绍

DrawerLayout是在Slidingmenu出现之后的产物。

NavigationView介绍

NavigationView是Design Support库中提供的一个控件,因此使用时需要把这个库引入到项目中才行。

打开app/build.gradle文件,在dependencies闭包中添加如下内容

compile 'com.android.support:design:24.2.1'
compile 'de.hdodenhof:circleimageview:2.1.0'

 第一行是Design Support库,第二行是一个开源项目CircleImageView,该项目可用来轻松实现图片原型化的功能,它的项目地址是https://github.com/hdodenhof/CircleImageView

1.toolbar.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <android.support.v7.widget.Toolbar
 3     xmlns:android="http://schemas.android.com/apk/res/android"
 4     xmlns:app="http://schemas.android.com/apk/res-auto"
 5     android:id="@+id/toolbar_custom"
 6     android:layout_width="match_parent"
 7     android:layout_height="?attr/actionBarSize"
 8     android:background="?attr/colorPrimary"
 9     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
10     app:popupTheme="@style/Theme.AppCompat.Light"
11     >
12 </android.support.v7.widget.Toolbar>
View Code

相关文章:

  • 2022-01-04
  • 2018-01-11
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-01-21
  • 2023-01-06
  • 2021-08-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2021-06-26
  • 2021-12-08
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案