只有一个按钮的情况

<resources>
<string name="app_name">照片</string>
</resources>
styles.xml
<resources>

    <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <!-- Toolbar styles -->
<item name="toolbarStyle">@style/Widget.AppCompat.Toolbar</item>
</style> </resources>

mainActivity.java

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context="com.homelink.testtoolbar7.MainActivity"> <android.support.v7.widget.Toolbar
style="style/toolbarStyle"
android:id="@+id/my_toolbar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"> <ImageView
android:id="@+id/bluetoothState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/fm_detailitem_walk"
android:contentDescription="content_description_bluetooth_status"
android:padding="8dp"
android:layout_marginRight="10dp"
android:layout_gravity="right"/>
</android.support.v7.widget.Toolbar> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout>

android toolbar效果2的更多相关文章

  1. android toolbar效果4

    两个标题的,右边一个按钮 activity_main.xml: <android.support.v7.widget.Toolbar style="style/toolbarStyle ...

  2. android toolbar效果3

    Title居中,只有一个右边按钮 activity_main.xml: <?xml version="1.0" encoding="utf-8"?> ...

  3. android toolbar效果

    layout下的layout_main.xml: <?xml version="1.0" encoding="utf-8"?> <Relati ...

  4. [置顶] xamarin android toolbar(踩坑完全入门详解)

    网上关于toolbar的教程有很多,很多新手,在使用toolbar的时候踩坑实在太多了,不好好总结一下,实在浪费.如果你想学习toolbar,你肯定会去去搜索androd toolbar,既然你能看到 ...

  5. Android Toolbar中的title居中问题

    版权声明:本文为xing_star原创文章,转载请注明出处! 本文同步自http://javaexception.com/archives/167 Android Toolbar中的title居中问题 ...

  6. Android动画效果之自定义ViewGroup添加布局动画

    前言: 前面几篇文章介绍了补间动画.逐帧动画.属性动画,大部分都是针对View来实现的动画,那么该如何为了一个ViewGroup添加动画呢?今天结合自定义ViewGroup来学习一下布局动画.本文将通 ...

  7. Android动画效果之Property Animation进阶(属性动画)

    前言: 前面初步认识了Android的Property Animation(属性动画)Android动画效果之初识Property Animation(属性动画)(三),并且利用属性动画简单了补间动画 ...

  8. Android动画效果之初识Property Animation(属性动画)

    前言: 前面两篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画).Frame Animation(逐帧动画)Andr ...

  9. Android动画效果之Frame Animation(逐帧动画)

    前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...

随机推荐

  1. Linux下的5种I/O模型(转)

    Linux下的五种I/O模型: l         阻塞I/O l         非阻塞I/O l         I/O复用(select.poll.epoll) l         信号驱动I/ ...

  2. Python 自动发送邮件

    简单邮件传输协议(SMTP)是一种协议,用于在邮件服务器之间发送电子邮件和路由电子邮件.Python提供smtplib模块,该模块定义了一个SMTP客户端会话对象,可用于使用SMTP或ESMTP侦听器 ...

  3. FCC JS基础算法题(12):Where do I belong(数组排序并找出元素索引)

    题目描述: 先给数组排序,然后找到指定的值在数组的位置,最后返回位置对应的索引.举例:where([1,2,3,4], 1.5) 应该返回 1.因为1.5插入到数组[1,2,3,4]后变成[1,1.5 ...

  4. find: paths must precede expression问题及解决

    用find命令查找时 例如命令 会出错,查文档找出 find: paths must precede expression Usage: find [-H] [-L] [-P] [-Olevel] [ ...

  5. Sql Server索引重建

    公司线上数据有几千万数据,有时候索引碎片会导致索引达不到我们的预期查询效率,这个时候将索引重建将会提升一定效率,不过重建的时候一定得晚上用户少的时候,索引重建需要一定时间. 直接贴自动重建索引脚本吧 ...

  6. React-Native新列表组件FlatList和SectionList学习 | | 联动列表实现

    React-Native在0.43推出了两款新的列表组件:FlatList(高性能的简单列表组件)和SectionList(高性能的分组列表组件). 从官方上它们都支持常用的以下功能: 完全跨平台. ...

  7. 自由线程FreeThreadDOMDocument

    Posted on 2006年09月4日by 不及格的程序员-八神 星期二 天气:晴   昨天燕子 自己去五爱了 给我买了一堆袜子 给妈买了一双鞋 给自己买了一件 红色的内衣服 挺好看的 在市场买了一 ...

  8. .net平台常用组建

    常用的一些开源组件整理: 导出Excel报表的插件:NOPI.dll(基于微软OpenXml实现)开源的作业调度和自动任务框架:Quartz.NET用于大数据搜索引擎的全文检索框架:Lucene.ne ...

  9. git 错误汇总

    ★一.git提交时报错:Updates were rejected because the tip of your current branch is behind 出现这样的问题是由于:自己当前版本 ...

  10. yum源搭建

    1:vim /etc/yum.repo.d/ll.repo [local]   这里不能有空格,如[local yum] name=local baseurl=file:///yum gpgcheck ...