Flags

Lightweight android library for getting flag image for any country.

This entire library is only 175 kb. Can you believe that?

Simple, no nonsense, lightweight library for getting flag icon for any country from the two character country code

How this differs from other libraries?

There are plenty of open source libraries available for getting the flag icon.
But they all include separate image or vector files for each country (there are more than 250 flags in the world) hence become bulky.

Unlike all the other libraries, this one includes only ONE
sprite image
which consists of all the icons of
all the flags. And the icons are sliced from the sprite image when requested.

Demo Screenshot

flags

Usage

BitmapDrawable usFlag = Flags.forCountry("US")

That is all

How to include

As a dependency

  1. Add the JitPack repository to your build file
    Add it in your root build.gradle at the end of repositories:
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the dependency
dependencies {
  implementation 'com.github.jsramraj:flags:$version'
}

Just replace the $version with the appropriate version number, for e.g v1.0

Direct include

If, for some reason, you are not okay with adding a entire library, you can still use this by just adding two files into your project.

  • Give this library a star
  • Drag the sprite image that consists of all the flag icons into your project's asset folder
  • Add the Flags class to your project

That is all!!! you are good to go.

I want more clear images

This library is created to occupy very minimum space. So each flag size is only 32x22. If you want a higher resolution image, all you have to do is give a higher resolution image to this library.

You can use my another tool flag-sprite-creator to create higher resolution sprite image.
Find our more about the tool here.
The tool is deployed in heroku, you can find it here

GitHub