-
Notifications
You must be signed in to change notification settings - Fork 24
Android_Adding New Icons
It's to improve our UI further by changing the icons used throughout the app. In this post we'll change the icons in the Navigation Drawer menu, and in our FAB (Floating Action Button).
Material icons are designed by Google. They are intended to be simple, and easy to use in web, Android, and iOS projects. They are created using Google's design guidelines to depict in simple and minimal forms the universal concepts used commonly throughout a UI. We are going to be using these icons in our project.
In Android Studio, there's a feature called Vector Asset Studio that we are going to use to easily import new icons.
To access Vector Asset Studio, open your project in Android Studio, and right click on the res folder. Select New > Vector Asset and the Vector Asset Studio will open. Now select Material Icon and click on Choose. You will now be presented with a list of available icons. Choose one icon and click OK > Next > Finish. A new icon will be added to your project's drawable folder, and it's ready to be used.
Below you can see the sample code on how I changed the Navigation Drawer icons to use the new icons I imported using Vector Asset Studio.
<group
android:id="@+id/menu_top"
android:checkableBehavior="single">
<item
android:checked="true"
android:id="@+id/nav_my_profile"
android:icon="@drawable/ic_person_black_24dp"
android:title="My Profile" />
<item
android:id="@+id/nav_contacts"
android:icon="@drawable/ic_people_black_24dp"
android:title="My Contacts" />
</group>
<group
android:id="@+id/menu_bottom"
android:checkableBehavior="single">
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_settings_black_24dp"
android:title="Settings" />
<item
android:id="@+id/nav_send_feedback"
android:icon="@drawable/ic_menu_send"
android:title="Send Feedback" />
</group>
All the icons that you can import are black, but you shouldn't be worried. All you need to do to change the color is use the android:tint
attribute on the element that's using the icon. Below you can see how I changed the color of the icon on my FloatingActionButton
:
android:src="@drawable/ic_create_black_24dp"
android:tint="@color/colorBackground"
Google has really helped us by providing ready made set of icons that we can use in our Android application. Importing and using the icons couldn't be simpler. Below are the end result of the changes I made to the app:
- Android
- Getting Started
- Project Structure
- Gradle
- Menu
- Theming
- Login Screen
- Menu & Navigation
- Importing Library From GitHub
- Creating Reusable Layouts
- Adding New Icons
- Profile Screen
- Chat Screen
- Contacts Screen
- Pending Invites Screen
- Settings Screen
- Add Library Dependency
- Discover Users Screen
- Splash Screen
- Auth0
- Authentication Logic
- Profile Screen Logic
- Send Feedback
- Authenticated to Firebase via Auth0
- Saving User Info to Firebase
- Storing User Connection Info to Firebase
- Calculating Distance Between Users
- Chat Logic
- Handling Device Rotation
- Android Other
- Ionic
- Getting Started
- Project Structure
- Menu
- Theming
- Login Screen
- Adding Images
- Creating Reusable Layouts
- Adding New Icons
- Profile Screen
- Contact Screen
- Elastic Textarea
- Chat Bubble
- Chat Screen
- Contacts Screen
- Pending Invites Screen
- Settings Screen
- Discover Users Screen
- Splash Screen
- Animations
- Auth0
- Storing User Data
- Profile Screen Logic
- Send Feedback
- Update to Ionic RC0
- Reimplemented Auth0 with Ionic RC0
- Authenticated to Firebase via Auth0
- Saving User Info to Firebase
- Storing User Connection Info to Firebase
- Calculating Distance Between Users
- Chat Logic
- Handling Device Rotation
- Ionic Other
- Version Updating
- Cordova
- Other
- Messaging