material-components

How to change toolbar back button icon in android material components

坚强是说给别人听的谎言 提交于 2021-02-19 05:11:51
问题 I would like to change the default navigate up icon (back button icon) to my custom icon. I not using a drawer, just a simple toolbar and material components Is this possible? 回答1: If you are using a Toolbar to change the icon just use: Toolbar toolbar = findViewById(R.id.xxx); toolbar.setNavigationIcon(R.drawable.xxxx4); setSupportActionBar(toolbar); If you are using the ActionBar you can use: getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R

How to change toolbar back button icon in android material components

被刻印的时光 ゝ 提交于 2021-02-19 05:10:07
问题 I would like to change the default navigate up icon (back button icon) to my custom icon. I not using a drawer, just a simple toolbar and material components Is this possible? 回答1: If you are using a Toolbar to change the icon just use: Toolbar toolbar = findViewById(R.id.xxx); toolbar.setNavigationIcon(R.drawable.xxxx4); setSupportActionBar(toolbar); If you are using the ActionBar you can use: getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R

Different corner radius values for a MaterialCardView

£可爱£侵袭症+ 提交于 2021-02-18 22:27:08
问题 Is is possible to have different values for each corner radius of a MaterialCardView? And if so how? I tried something like the code below but it doesn't seem to have any effect float radius = getContext().getResources().getDimension(R.dimen.default_corner_radius); ShapePathModel leftShapePathModel = new ShapePathModel(); leftShapePathModel.setTopLeftCorner(new RoundedCornerTreatment(radius)); leftShapePathModel.setTopRightCorner(new RoundedCornerTreatment(radius)); MaterialShapeDrawable bg =

Change style of the right icon error TextInputLayout

依然范特西╮ 提交于 2021-02-18 15:12:24
问题 I want to change the style of the right icon error (the image with ! sign) in a TextInputLayout but I don't find how. It is possible?. 回答1: With the Material Component Library just use the app:errorIconDrawable attribute. Something like: <com.google.android.material.textfield.TextInputLayout app:errorIconDrawable="@drawable/..." ../> 回答2: To do this in your Java class, you can do something like this: // initialize your drawable object Drawable myErrorDrawable = getResources().getDrawable(R

Change style of the right icon error TextInputLayout

别等时光非礼了梦想. 提交于 2021-02-18 15:11:19
问题 I want to change the style of the right icon error (the image with ! sign) in a TextInputLayout but I don't find how. It is possible?. 回答1: With the Material Component Library just use the app:errorIconDrawable attribute. Something like: <com.google.android.material.textfield.TextInputLayout app:errorIconDrawable="@drawable/..." ../> 回答2: To do this in your Java class, you can do something like this: // initialize your drawable object Drawable myErrorDrawable = getResources().getDrawable(R

Change style of the right icon error TextInputLayout

ぐ巨炮叔叔 提交于 2021-02-18 15:10:45
问题 I want to change the style of the right icon error (the image with ! sign) in a TextInputLayout but I don't find how. It is possible?. 回答1: With the Material Component Library just use the app:errorIconDrawable attribute. Something like: <com.google.android.material.textfield.TextInputLayout app:errorIconDrawable="@drawable/..." ../> 回答2: To do this in your Java class, you can do something like this: // initialize your drawable object Drawable myErrorDrawable = getResources().getDrawable(R

Change style of the right icon error TextInputLayout

对着背影说爱祢 提交于 2021-02-18 15:09:55
问题 I want to change the style of the right icon error (the image with ! sign) in a TextInputLayout but I don't find how. It is possible?. 回答1: With the Material Component Library just use the app:errorIconDrawable attribute. Something like: <com.google.android.material.textfield.TextInputLayout app:errorIconDrawable="@drawable/..." ../> 回答2: To do this in your Java class, you can do something like this: // initialize your drawable object Drawable myErrorDrawable = getResources().getDrawable(R

Add custom shape ripple with selector on navigationview menu item

假装没事ソ 提交于 2021-02-10 05:47:28
问题 I want to add a ripple effect with rounded corners rectangle with a selector for navigation view item. But it keeps adding the gray rectangle ripple effect. navigation view <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" app:itemIconTint="@color/drawer_item" app

Changing NavigationView background to round shape not working when pressed

人盡茶涼 提交于 2021-02-06 13:46:48
问题 I am setting navigation item background using app:itemBackground in layout: <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:itemBackground="@drawable/nav_selector_background" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer"/> Here is nav_selector_background.xml <ripple xmlns:android="http://schemas

Navigation drawer rounded corner background for items

我是研究僧i 提交于 2021-02-06 12:13:37
问题 I want to have a rounded corner for the items in navigation drawer like this : it's an example of material design in material.io website is it possible ? 回答1: Just use the app:itemShapeAppearanceOverlay attribute: <com.google.android.material.navigation.NavigationView app:itemShapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Nav" ...> with: <style name="ShapeAppearanceOverlay.Nav" parent=""> <item name="cornerFamily">rounded</item> <item name="cornerSize">8dp</item> </style> 回答2: First, I