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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With