How to add Vector image support to old Android versions using new AppCompat?


Finally we had vector support for all Android versions, 8-)

  • bye bye all different PNG size files in different drawable folders!
  • bye bye FontAwesome!
  1. first of all add these dependencies to your module’s build.gradle:
dependencies {
    compile ''
    compile ''
  1. add this to your android defaultConfig tag in your module’s build.gradle:
android {

    defaultConfig {
        vectorDrawables.useSupportLibrary = true
  1. replace all your ImageView with
    and ImageButton with in all your project’s xml layouts.

  2. replace all android:src attribute in all ImageView with app:srcCompat.

  3. now import your vector image using New -> “Vector Asset” submenu by right clicking on your drawable folder…

That’s it!!!

How to create a toggle button with custom image and no text in Android


Create a file ic_toggle.xml in your res/drawable folder

<selector xmlns:android="">
 android:drawable="@drawable/ic_slide_switch_off" />
 android:drawable="@drawable/ic_slide_switch_on" />

Here @drawable/ic_slide_switch_on & @drawable/ic_slide_switch_off are images you create.

Then create another file in the same folder, name it ic_toggle_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">
<item android:id="@+android:id/background" 
 android:drawable="@android:color/transparent" />
<item android:id="@+android:id/toggle"
 android:drawable="@drawable/ic_toggle" />

Now add to your custom theme, (if you don’t have one create a styles.xml file in your res/values/folder)

<style name="Widget.Button.Toggle" parent="android:Widget">
 <item name="android:background">@drawable/ic_toggle_bg</item>
 <item name="android:disabledAlpha">?android:attr/disabledAlpha</item>

<style name="toggleButton" parent="@android:Theme.Black">
<item name="android:buttonStyleToggle">@style/Widget.Button.Toggle</item>
<item name="android:textOn"></item>
<item name="android:textOff"></item>

This creates a custom toggle button for you.
Now use the custom style and background in your view.


How to use Google Analytic for your app



The Google Analytics SDK for Android makes it easy for developers to collect user engagement data from their apps. Developers can then use the Google Analytics app-tracking reports to measure:

  • The number of active users are using their applications.
  • From where in the world the application is being used.
  • Adoption and usage of specific features.
  • In-app purchases and transactions.
  • The number and type of application crashes.
  • And many other useful metrics.