How to enable/disable toolbar scrolling programmatically when using design support library

The Toolbar, being a child of the AppBarLayout, gets its LayoutParams from the AppBarLayout. These layout params have the scroll flags that are set in the XML. So, you get the AppBarLayout.LayoutParams from the Toolbar, and call setScrollFlags() to change the flags to the value you want. Toolbar toolbar = findViewById(R.id.toolbar); // or however you … Read more

Recycler view item fill up entire recycler view height after upgrading support library from “23.1.1” to “23.2.1”

Update It appears that you are updating the LayoutParam for your View in your Adapter. It is possible to tell this because your UI appears absolutely fine until you begin scrolling. This means that your XML is correct as it is defined in your XML layout file. The fact that it changes after scrolling begins, … Read more

How to set maximum expanded height in android support design bottom sheet?

to stop the bottom sheet from moving up the full screen is simple, just set a layout_height for your NestedScrollView to 500dp, also you probably want to set it’s layout_gravity=”bottom” <android.support.v4.widget.NestedScrollView android:id=”@+id/design_bottom_sheet” android:layout_width=”match_parent” android:layout_height=”500dp” android:background=”#000000″ android:layout_gravity=”bottom” app:behavior_hideable=”true” app:behavior_peekHeight=”100dp” app:layout_behavior=”android.support.design.widget.BottomSheetBehavior”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical”> <TextView android:layout_width=”match_parent” android:layout_height=”100dp” android:layout_marginBottom=”5dp” android:background=”#e444ff” /> <TextView android:layout_width=”match_parent” android:layout_height=”100dp” android:layout_marginBottom=”5dp” android:background=”#e444ff” /> … Read more

Android CollapsingToolbarLayout Title background

Use a text protection scrim(scroll down a bit). My example assumes the title text is white, so some tweaks may be necessary to optimize for your case. Inside your CollapsingToolbarLayout, add the following after ivBigImage: <View android:layout_width=”match_parent” android:layout_height=”@dimen/sheet_text_scrim_height_top” android:background=”@drawable/scrim_top” app:layout_collapseMode=”pin”/> <View android:layout_width=”match_parent” android:layout_height=”@dimen/sheet_text_scrim_height_bottom” android:layout_gravity=”bottom” android:layout_alignBottom=”@+id/image” android:background=”@drawable/scrim_bottom”/> In your Drawable folder, add: scrim_top.xml <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <gradient … Read more

How do I change the default height of a BottomSheetDialog?

You can set a bottomSheetDialogTheme in your Activity, overriding the bottomSheetStyle attribute’s behavior_peekHeight: <style name=”AppTheme” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”bottomSheetDialogTheme”>@style/AppBottomSheetDialogTheme</item> </style> <style name=”AppBottomSheetDialogTheme” parent=”Theme.Design.Light.BottomSheetDialog”> <item name=”bottomSheetStyle”>@style/AppModalStyle</item> </style> <style name=”AppModalStyle” parent=”Widget.Design.BottomSheet.Modal”> <item name=”behavior_peekHeight”>@dimen/custom_peek_height</item> </style> This same technique can be used for other attributes as well, such as adding <item name=”behavior_hideable”>true</item> to the AppModalStyle to change whether the bottom … Read more

Using BottomSheetBehavior with a inner CoordinatorLayout

I have finally released my implementation. Find it on Github or directly from jcenter: compile ‘com.otaliastudios:bottomsheetcoordinatorlayout:1.0.0’ All you have to do is using BottomSheetCoordinatorLayout as the root view for your bottom sheet. It will automatically inflate a working behavior for itself, so don’t worry about it. I have been using this for a long time … Read more

Rounded corners on material button

With the Material Components Library:. Add the dependency to your build.gradle: dependencies { implementation ‘com.google.android.material:material:1.3.0’ } In this case you can use a MaterialButton in your layout file: <com.google.android.material.button.MaterialButton …. style=”@style/Widget.MaterialComponents.Button” app:cornerRadius=”..” app:strokeColor=”@color/colorPrimary”/> Use app:cornerRadius attribute to change the size of corner radius. This will round off the corners with specified dimensions. You can also … Read more