如何将扩展工具栏的标题放在后退箭头旁边?

如何将扩展工具栏的标题放在后退箭头旁边?

问题描述:

我有一个扩展Toolbar但它的标题是越来越放置在中心这样的:如何将扩展工具栏的标题放在后退箭头旁边?

enter image description here

这里是我的代码:

<android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:elevation="0dp" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/appbar_height" 
      android:minHeight="?android:attr/actionBarSize" 
      android:background="@color/colorPrimaryLight" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 

    </android.support.design.widget.AppBarLayout> 

我怎样才能地方这个称号靠近回到那里的箭头?

请让我知道。

+0

好了,您需要使用'CollapsingToolbarLayout'这就是这并不是一个好主意,并且像这样扩展了'工具栏' – Mohsen

+0

,但这不是一个可滚动的活动......工具栏应该只保留这个大小。 –

+0

它不能这样,至少,添加一个'ImageView'(或一个绿色的视图)没有任何效果,只是,让'工具栏'做他的工作:) – Mohsen

做这样的:

<android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay" 
      app:elevation="0dp"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="270dp" 
       android:background="@color/colorPrimary" 
       android:minHeight="?android:attr/actionBarSize" 
       app:popupTheme="@style/AppTheme.PopupOverlay"> 

       <TextView 
        android:id="@+id/toolbar_title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="top" 
        android:text="Toolbar Title" /> 

      </android.support.v7.widget.Toolbar> 

     </android.support.design.widget.AppBarLayout> 

或者删除android:text然后设置标题:

Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar); 
TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title); 

输出:

enter image description here

+1

使用'getSupportActionBar()。setDisplayShowTitleEnabled(false);'从工具栏中删除已经给定的标题。 –

+0

@HammadNasir我认为相同,但是在'TextView'上设置'工具栏'是怎么回事?或者你试图只删除标题? – Mohsen