Android - Activity Home/Up arrow has additional padding/margin with SDK 24

前端 未结 3 1176
再見小時候
再見小時候 2021-01-31 19:12

I\'ve just updated my app from using SDK 23 to SDK 24.

A problem has arisen for my activities that have show the Up/Home arrow (i.e., getSupportActionBar().setDisp

3条回答
  •  爱一瞬间的悲伤
    2021-01-31 19:41

    I think that this padding is a new standard to match Material spec in SDK 24. First you must hide default toolbar title by this code:

    getSupportActionBar().setDisplayShowTitleEnabled(false);

    Then make a file called toolbar.xml and add these codes in that file:

    
    
        
            android:layout_marginStart="16dp"
            android:gravity="left|center"
            android:text="Toolbar Title" 
            android:textColor="@color/white" 
            android:textSize="20sp"
            android:fontFamily="sans-serif-medium"/>
    
    
    

    As you see, you can control everything in this file. Look at this line in toolbar.xml :

    app:contentInsetStartWithNavigation="0dp"

    This is what you want. Goodluck.

提交回复
热议问题