簡體   English   中英

不需要的左邊距/工具欄中的徽標填充

[英]Unwanted left margin/padding to logo in 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>

您的xml似乎正確,代碼中沒有問題,可能是圖像問題,因此將其替換為正確的圖像,您肯定可以使用gimp,photoshop等圖像編輯器進行檢查,在ic_parking圖像內將有一個內部填充,您可以將其設置為工具欄商標。

您可以使用另一張圖片替換它,該圖片本身沒有任何內部填充,希望您了解我要說的是什么。

問候。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM