Floating action bar is an attractive implementation in android material design. Any one can do special activity with the help of this button.
How to change floating action bar(fab) color as android developer:
Method 1: Change floating action bar(fab) color in xml:
To change floating action bar(fab) color just follow this step
just add “app:backgroundTint=”#colorcode” ” in xml of floating action bar(fab) ..Β For example
1 |
app:backgroundTint="#8393ca" |
at the place of #8393ca add any color code you want
Example as usaage..
1 2 3 4 5 6 7 8 |
<android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" app:backgroundTint="#8393ca" android:src="@drawable/send" /> |
Method 2: Change floating action bar color programmatically
just add this line on your code
Firstly create a color red in your values=>colors then add this code in your activity on create
1 |
fab.setBackgroundTintList(getResources().getColorStateList(R.color.red)); |
or
1 |
fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#33691E"))); |
Then your floating action bar(fab)’s background color will be red. π
That’s all for today .. For more attractive trick stay with androidrace π