首页 > 解决方案 > 删除工具栏中 ImageView 和后退箭头之间的空间

问题描述

我想删除工具栏中内置后退箭头和 SimpleDraweeView 之间的空格。

fragment_chat_profile.xml

<android.support.design.widget.CoordinatorLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   xmlns:fresco="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="wrap_content">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay" >

    <android.support.v7.widget.Toolbar
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:contentInsetStartWithNavigation="0dp"
        app:popupTheme="@style/AppTheme.PopupOverlay" >

        <ImageView
            android:id="@+id/profile_photo"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:src="@drawable/default_profile" />

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

快照显示我必须删除的空间。

要删除的空间

ChatActivity.java 按活动设置工具栏。activity_container_void 只包含一个空视图。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_container_void);

    ActionBar actionBar = getSupportActionBar();
    View customView = LayoutInflater.from(this).inflate(R.layout.fragment_chat_profile, null);
    Objects.requireNonNull(actionBar).setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setCustomView(customView);
}

清单.xml

<activity
        android:name=".home.chat.ChatActivity"
        android:parentActivityName=".home.MainActivity"/>

我尝试了不同的解决方案,但没有一个有效。请帮我。

标签: javaandroidandroid-layouttoolbar

解决方案


推荐阅读