简体   繁体   中英

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. 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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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