Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何删除向上导航箭头和工具栏标题之间的填充?_Android_Xml_Android Layout_Toolbar_Android Toolbar - Fatal编程技术网

Android 如何删除向上导航箭头和工具栏标题之间的填充?

Android 如何删除向上导航箭头和工具栏标题之间的填充?,android,xml,android-layout,toolbar,android-toolbar,Android,Xml,Android Layout,Toolbar,Android Toolbar,顶部是设置时向上导航箭头的默认填充 getSupportActionBar().setDisplayHomeAsUpEnabled(true) 我希望工具栏看起来更像底部图像,因为我希望标题指示向上导航箭头将用户发送到的位置,而不是当前活动的描述。到目前为止,我已经尝试将自定义文本视图添加到工具栏,并根据类似问题设置app:contentInsetStartWithNavigation=“0dp”。但正如作者所指出的,这并没有删除箭头右侧的填充。如何使工具栏看起来更像第二个图像?“我的工具栏”的

顶部是设置时向上导航箭头的默认填充

getSupportActionBar().setDisplayHomeAsUpEnabled(true)

我希望工具栏看起来更像底部图像,因为我希望标题指示向上导航箭头将用户发送到的位置,而不是当前活动的描述。到目前为止,我已经尝试将自定义文本视图添加到工具栏,并根据类似问题设置
app:contentInsetStartWithNavigation=“0dp”
。但正如作者所指出的,这并没有删除箭头右侧的填充。如何使工具栏看起来更像第二个图像?“我的工具栏”的当前xml如下所示:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_doc"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="?attr/actionBarTheme"
    app:contentInsetStartWithNavigation="0dp"
    app:layout_constraintTop_toTopOf="parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:gravity="left"
        android:id="@+id/txtTitle"
        android:textColor="#FFFFFF"/>

</android.support.v7.widget.Toolbar>

我进一步为菜单提供了xml,我使用菜单充气器将其添加到工具栏中。另一个解决方案是在菜单中添加箭头图标和文本视图?但是,我不确定如何让新的箭头图标具有相同的向上导航行为

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/ic_baseline_home_24px"
        app:showAsAction="always"/>
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        app:showAsAction="never" />
</menu>

尝试将
app:contentInsetStart
设置为
0dp
而不是
app:contentInsetStartWithNavigation

    <android.support.v7.widget.Toolbar
        ...
        app:contentInsetStart="0dp">

这将产生与app:contentInsetStartWithNavigation=“0dp”
相同的间距。我还尝试设置
app:contentInsetLeft=“0dp”