您的位置:首页 > 其它

MD设计之ToolBar

2015-10-21 10:54 309 查看
ToolBar是在android v7包中,使用时在gradle 中添加:compile'com.android.support:appcompat-v7:22.2.1' 其中22.2.1是v7包的版本,根据具体环境选择!

注意:xml文件中使用的时候一定注意ToolBar和android.support.v7.widget.Toolbar的区别,不要导错了, 如果要设置标题居中,只需要在布局里加入一个textview即可

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:backgroundTint="#ff0000"
app:subtitle="subtool"
app:navigationIcon="@drawable/ic_launcher"
app:title="tool"
app:titleTextColor="@color/abc_search_url_text"
app:titleMargins="10dp">

<TextView
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="20sp"
android:text="tool"/>
</android.support.v7.widget.Toolbar>

</RelativeLayout>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: