android toolbar效果3

Title居中,只有一个右边按钮

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:gravity="center"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Toolbar Title"
            android:layout_gravity="center"
            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
            android:id="@+id/toolbar_title" />


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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-07-31
  • 2022-12-23
猜你喜欢
  • 2021-06-28
  • 2022-03-06
  • 2021-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-05-01
相关资源
相似解决方案