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/

Implementing SearchView as per the material design guidelines

I tried several material SearchView libraries, but none of them worked good as the one from the support library, so I decided to redesign it, after a lot of work, I am pleased with the result: Here is how you can do it: 1) Add SearchView item to your menu <item android:id=”@+id/m_search” android:icon=”@drawable/ic_action_search” android:title=”@string/search_title” app:actionLayout=”@layout/search_view_layout” … Read more

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

Material design button with border

You can also use the Material Components for Android. Add the dependency to your build.gradle: dependencies { implementation ‘com.google.android.material:material:1.3.0’ } In this case you can use the MaterialButton in your layout file: <com.google.android.material.button.MaterialButton …. style=”@style/Widget.MaterialComponents.Button.OutlinedButton” app:cornerRadius=”..” app:strokeColor=”@color/colorPrimary”/> Apply the style @style/Widget.MaterialComponents.Button.OutlinedButton. In your case use the app:cornerRadius attribute to change the size of corner radius. … 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:

Put constant text inside EditText which should be non-editable – Android

Did u try this method? final EditText edt = (EditText) findViewById(R.id.editText1); edt.setText(“http://”); Selection.setSelection(edt.getText(), edt.getText().length()); edt.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)