2017-01-20 17 views
0

アクションバーに戻るボタン(上ボタン)が表示されていますが、バーの中央に表示されません。戻る矢印ボタンがアンドロイドのツールバーの中央に配置されていません

としては、私はツールバーの最小高さを設定していると私はそれを変更できない

enter image description here

この画像で見ることができます。次のように

私のXMLコードは次のとおりです。

<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <android.support.design.widget.AppBarLayout 
       android:id="@+id/app_bar" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:theme="@style/AppTheme.AppBarOverlay"> 

       <android.support.v7.widget.Toolbar 
        android:id="@+id/offence_title" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="center" 
        android:gravity="center" 
        android:background="?attr/colorPrimary" 
        android:minHeight="150dip" 
        android:paddingBottom="15dp" 
        android:paddingTop="15dp" 
        android:theme="?attr/actionBarTheme" 
        android:paddingRight="15dp"> 

        <TextView 
         android:id="@+id/toolbar_title" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:maxLines="3" 
         android:textColor="#FFF" 
         android:textSize="25sp" /> 
       </android.support.v7.widget.Toolbar> 

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

      <TextView 
       android:id="@+id/fine_bold" 
       style="?android:attr/textAppearanceLarge" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/app_bar" 
       android:padding="16dp" 
       android:textIsSelectable="true" 
       android:textSize="25sp" 
       android:textStyle="bold" /> 

      <TextView 
       android:id="@+id/offence_details" 
       style="?android:attr/textAppearanceLarge" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/fine_bold" 
       android:padding="16dp" 
       android:textIsSelectable="true" /> 
     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 

答えて

1

あなたandroid.support.v7.widget.Toolbar

などからパディングトップを取り外し:あなたのにandroid:layout_widthを設定する必要があり

<android.support.v7.widget.Toolbar 
       android:id="@+id/offence_title" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_gravity="center" 
       android:gravity="center" 
       android:background="?attr/colorPrimary" 
       android:minHeight="150dip" 
       android:paddingBottom="15dp" 
       android:paddingTop="15dp" //remove this line from your xml 
       android:theme="?attr/actionBarTheme" 
       android:paddingRight="15dp"> 
0

カスタム高さa nd android:minHeight?attr/actionBarSize。これにより固定された要素が上部に沿って(minHeightの中心に)表示され、高さ全体がさらに大きな高さに拡大されます。

<android.support.v7.widget.Toolbar 
    android:id="@+id/offence_title" 
    android:layout_width="match_parent" 
    android:layout_height="150dip" 
    android:layout_gravity="center" 
    android:gravity="center" 
    android:background="?attr/colorPrimary" 
    android:minHeight="?attr/actionBarSize" 
    android:paddingBottom="15dp" 
    android:paddingTop="15dp" 
    android:theme="?attr/actionBarTheme" 
    android:paddingRight="15dp"> 
関連する問題