Android floating action button tutorial

Опубликовано: 24 Декабрь 2016
на канале: Coding Demos
30 тыс
16

In this tutorial you will learn how to use Android floating action button to make a phone call using Android support design library.
Here is how to do it:

- Add android support library to Gradle build (Module:app):
(compile 'com.android.support:design:25.1.0')
- Add Android floating action button to xml screen layout
- Set the appropriate icon that you need for the button like this:
(app:srcCompat=" and make sure that the icon is placed under drawable folder in your android project.
- You can download the icons from material design icon website provided by Google:
- Make sure the size of the downloaded icon is 24dp
- Set a margin of 16dp from the right and bottom of the screen like this: (android:layout_marginBottom="16dp") & (android:layout_marginRight="16dp")
- Set the position of android floating action button at the bottom right of the screen as follows: (android:layout_gravity="bottom|end")
- Change floating action button size from mini to normal like this:
(app:fabSize="normal")
- You can change button color to any color that you want like this:
(app:backgroundTint="
- Now we define the android floating action button inside java class and then setOnClickListener for it to be able to make a call.
- To make a phone call you will need to start a new intent like this:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("tel://" + phone)));

And we're done!!

Social media:
▶Twitter:


Смотрите видео Android floating action button tutorial онлайн без регистрации, длительностью 20 минут 14 секунд в хорошем hd качестве. Это видео добавил пользователь Coding Demos 24 Декабрь 2016, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 30 тысяч раз и оно понравилось 16 людям.