MaterialCardView crashes with material:1.1.0

you can just keep it in your materialcardview itself also: <com.google.android.material.card.MaterialCardView android:layout_width=”match_parent” android:layout_height=”wrap_content” app:cardCornerRadius=”8dp” **** android:theme=”@style/Theme.MaterialComponents.Light” ***** app:cardElevation=”8dp”>

What’s the difference between the CardView from com.google.android.material and android.support.v7.widget

There are 3 versions: android.support.v7.widget.CardView: it is provided by the old support libraries and it is deprecated. androidx.cardview.widget.CardView it is the androidx version and it replaced the support libraries. To use it you have to add the dependency implementation ‘androidx.cardview:cardview:x.x.x’. com.google.android.material.card.MaterialCardView is provided by the Material Components Library. To use it you have to add … Read more

Can’t change background color on MaterialButton without change colorAccent

1st Solution You can use app:backgroundTint to change back ground color of MaterialButton <com.google.android.material.button.MaterialButton android:id=”@+id/bittrexJsonViewButton” android:layout_width=”0dp” android:layout_height=”@dimen/min_height” android:layout_marginStart=”@dimen/half_default_margin” android:layout_marginEnd=”@dimen/half_default_margin” app:backgroundTint=”@android:color/holo_orange_dark” android:text=”@string/json_view” app:layout_constraintBottom_toBottomOf=”@+id/binanceJsonViewButton” app:layout_constraintEnd_toEndOf=”parent” app:layout_constraintStart_toEndOf=”@+id/binanceJsonViewButton” app:layout_constraintTop_toTopOf=”@+id/binanceJsonViewButton” /> 2nd Solution MaterialButton uses colorPrimary as background when button is in active state and colorOnSurface when disabled. So, you can define it in your theme and apply it on … Read more

Android Chip Custom Height Or Padding – Chipgroup spacing

In the 1.1.0-alpha* versions extra spacing is added for the chip. After a lot of hit and trial I managed to remove that spacing using: app:chipMinTouchTargetSize=”0dp” Looking at the class file for Chip, it seems that it’s related to Android’s minimum touch target size, so consider that before changing this.

ChipGroup single selection

To prevent all chips from being deselected you can use the method setSelectionRequired: chipGroup.setSelectionRequired(true) You can also define it in the layout using the app:selectionRequired attribute: <com.google.android.material.chip.ChipGroup app:singleSelection=”true” app:selectionRequired=”true” app:checkedChip=”@id/…” ..> Note: This requires a minimum of version 1.2.0

Android material chip component crashing app. Unable to inflate xml

Update your app theme to inherit from one of these themes: Theme.MaterialComponents Theme.MaterialComponents.NoActionBar Theme.MaterialComponents.Light Theme.MaterialComponents.Light.NoActionBar Theme.MaterialComponents.Light.DarkActionBar For example: <style name=”AppTheme” parent=”Theme.MaterialComponents.Light.NoActionBar”> Note: Using a Material Components theme enables a custom view inflater Source: https://www.material.io/develop/android/docs/getting-started/

bottomSheetDialogFragment full screen

In your custom BottomSheetDialogFragment you can use something like: @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialogInterface; setupFullHeight(bottomSheetDialog); } }); return dialog; } private void setupFullHeight(BottomSheetDialog bottomSheetDialog) { FrameLayout bottomSheet = (FrameLayout) bottomSheetDialog.findViewById(R.id.design_bottom_sheet); BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet); ViewGroup.LayoutParams … Read more

How to center icon in a MaterialButton which has no text?

Found it. The attribute I was missing was app:iconPadding=”0dp”. So, from my experiments, the minimum attributes needed to create a square MaterialButton which has a centred icon and no text is the following: <com.google.android.material.button.MaterialButton android:layout_width=”52dp” android:layout_height=”52dp” android:insetLeft=”0dp” android:insetTop=”0dp” android:insetRight=”0dp” android:insetBottom=”0dp” app:icon=”@drawable/icon_next” app:iconGravity=”textStart” app:iconPadding=”0dp” /> These attributes produce a MaterialButton as follows: