只有一个按钮的情况

<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>

最新文章

  1. 批量 kill mysql 中运行时间长的sql
  2. android sdk 国内镜像地址
  3. 加速chrome之Vimium快捷键
  4. 【Python】迭代器、生成器、yield单线程异步并发实现详解
  5. Leetcode#56 Merge Intervals
  6. 用bat使用date和time命令
  7. BZOJ 3994 约数个数和
  8. 数学(矩阵乘法):HDU 4565 So Easy!
  9. iOS keyChain(钥匙串)的简单使用
  10. Codeforces Round #367 (Div. 2)D. Vasiliy&#39;s Multiset (字典树)
  11. 织梦CMS去广告方法 for DedeCMS V5.7
  12. 看图说话,P2P 分享率 90% 以上的 P2P-CDN 服务,来了!
  13. JAVA BigDecimal 用法
  14. angularJS常用的内置方法
  15. php 5.3.10 cli 模式加载php_openssl.dll
  16. C# winform 去掉button的边框颜色
  17. npm 删除node_modules
  18. android:shape的使用(+圆角ListView)(转)
  19. &quot;类工厂模式&quot;改写SqlHelper
  20. php面试题,百度答案

热门文章

  1. 清除微信小程序的缓存
  2. FCC JS基础算法题(2):Check for Palindromes(检查回文字符串)
  3. case语法2
  4. thinkPHP 分页样式增加下拉列表
  5. CSS-精灵图片的使用(从一张图片中截图指定位置图标)
  6. extjs_10_自己定义combotree组件
  7. linux学习笔记(二:权限)
  8. SUID、SGID、粘滞位
  9. 打印 laravel 模型查询产品的 SQL
  10. django 神奇的双下划线,通过外键的三种查询方式