2016-03-23 147 views
2

This is my application toolbar工具欄中不需要的左邊距/填充徽標

我以下面的方式添加了菜單按鈕和徽標。

final ActionBar ab = getSupportActionBar(); 
ab.setHomeAsUpIndicator(R.drawable.ic_menu); 
getSupportActionBar().setLogo(R.drawable.ic_parking); 

我試過在工具欄xml中使用doling,但它沒有幫助。

android:contentInsetLeft="0dp" 
android:contentInsetStart="0dp" 
app:contentInsetLeft="0dp" 
app:contentInsetStart="0dp" 
android:contentInsetRight="0dp" 
android:contentInsetEnd="0dp" 
app:contentInsetRight="0dp" 
app:contentInsetEnd="0dp" 

我想要做的是讓我的標誌接近菜單按鈕並應用一些填充。

更新 這裏是我的xml文件

<RelativeLayout 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:orientation="vertical" 
    android:id="@+id/root_login_activity" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_collapseMode="pin" 

     android:contentInsetLeft="0dp" 
     android:contentInsetStart="0dp" 
     app:contentInsetLeft="0dp" 
     app:contentInsetStart="0dp" 
     android:contentInsetRight="0dp" 
     android:contentInsetEnd="0dp" 
     app:contentInsetRight="0dp" 
     app:contentInsetEnd="0dp" 

     /> 

    <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/layout_margin" 
     android:paddingLeft="@dimen/layout_margin" 
     android:paddingRight="@dimen/layout_margin" 
     android:paddingTop="@dimen/layout_margin" 
     android:layout_below="@+id/toolbar" 
     android:background="@drawable/background" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      > 
     </RelativeLayout> 
    </android.support.v4.widget.NestedScrollView> 

</RelativeLayout> 
+0

你可以發表你的XML –

+0

嘗試設置標題爲空字符串getSupportActionBar()的setTitle(「); –

+0

冠軍在出現在標誌的右邊,所以我不力認爲這是問題 – Tushar

回答

0

你的XML似乎是正確的有在代碼中它可能與你的形象問題不是問題,所以有合適的圖像取代它你絕對可以用圖像編輯器檢查像gimp,photoshop會在你的ic_parking圖像裏面有一個內部填充,你將其設置爲工具欄圖標。

你可以用另一張圖片替換它,而圖片本身沒有任何內部填充,希望你明白我到底想說什麼。

問候。

+0

我不知道如何,但答案工作! – Tushar

+0

嗯罰款這是圖像的常見問題,你可以檢查你的圖像在圖像編輯器工具它包含內部圖像本身的內部邊緣:) –