标签:idg 内容 parent encoding sign layout ati 需要 match
1.在activity的layout中添加toolbar
1 <?xml version="1.0" encoding="utf-8"?> 2 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="com.mazingtec.mazing.Hall"> 8 9 <android.support.design.widget.AppBarLayout 10 android:layout_width="match_parent" 11 android:layout_height="wrap_content"> 12 13 <android.support.v7.widget.Toolbar 14 android:id="@+id/toolbar" 15 android:layout_width="match_parent" 16 android:layout_height="?attr/actionBarSize" 17 android:background="@color/primary_dark_material_dark" /> 18 19 </android.support.design.widget.AppBarLayout> 20 21 <include layout="@layout/content_main" /> 22 23 </android.support.design.widget.CoordinatorLayout>
2.新建一个layout来放主要内容
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:orientation="vertical" android:layout_width="match_parent" 4 android:layout_height="match_parent"> 5 6 </LinearLayout>
3.代码中启用toolbar
1 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 2 toolbar.setTitle("Hall"); 3 setSupportActionBar(toolbar);
4.添加其他需要的按钮
标签:idg 内容 parent encoding sign layout ati 需要 match
原文地址:http://www.cnblogs.com/mazing/p/6691811.html