简体   繁体   English

如何在折叠的动作栏android中减少工具栏标题的左侧和底部空间?

[英]How to reduce left and bottom space from toolbar title in collapsing action bar android?

在此处输入图片说明 在此处输入图片说明

I need to reduce left and bottom space from toolbar title in collapsing action bar. 我需要减少折叠动作栏中工具栏标题的左侧和底部空间。 I need to do something like whats app. 我需要做一些类似Whats App的事情。 Here is my code. 这是我的代码。 Thanks for help. 感谢帮助。

  <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/img_profile"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/speaker1"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

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

add this below in your activity where you are setting the title 在您设置标题的活动中添加以下内容

 mBinding.collapseToolbar.setExpandedTitleMarginBottom((int) getResources().getDimension(R.dimen.contact_info_expanded_title_margin));
 mBinding.collapseToolbar.setExpandedTitleMarginStart((int) getResources().getDimension(R.dimen.contact_info_expanded_title_margin));

mBinding.collapseToolbar.setTitle("Toolbar title");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM