android - 不需要的左边距/填充到工具栏中的 Logo

标签 android layout toolbar android-toolbar

This is my application toolbar

我按以下方式添加了菜单按钮和 Logo 。

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

我已经尝试在工具栏 xml 中执行以下操作,但没有帮助。

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

我想要做的是让我的 Logo 靠近菜单按钮并对其应用一些填充。

更新 这是我的 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 图像中会有一个内部填充你是设置为工具栏标志。

您可以检查并用另一张图片替换它,该图片本身没有任何内边距,希望您能理解我想表达的意思。

问候。

关于android - 不需要的左边距/填充到工具栏中的 Logo ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36170525/

相关文章:

Android ==> 禁用多任务处理?

cakephp - 将 CSS 或 JS 链接到默认布局

layout - 如何在 SproutCore 中设置 LabelView 的文本大小

android - 单击 EditText View 时工具栏会扩展

c++ - 如何使用 TBSTYLE_FLAT 在 MFC CToolBar 上正确显示静态文本?

java - 将 JMenu ButtonGroups 与 JToolbar ButtonGroups 同步

android - 如何捕捉应用程序的结束?

Lollipop 中的 Android WebView 可访问性

Android设置View.GONE在listview中没有 "release"空间

android - 使用 androidannotations 触发 Intent