Skip to content

CountryPicker Libraries and Examples

In this tutorial we will look at some of the best Android CountryPicker libraries and how to use them.


A Country Code Picker Library.

Country Code Picker (CCP) is an android library which provides an easy way to search and select country phone code for the telephone number.

CCP gives professional touch to your well designed form like login screen, sign up screen, edit profile screen. CCP removes confusion about how to add number and thus make view more understandable. Finally reduces mistakes in user input.

The most recommended usage for CCP is using the default setting so the library will auto check the all the value. To do that, you need to follow the following steps:

  1. Add CCP view to layout
  2. Add EditText view to layout
  3. register the EditText using registerPhoneNumberTextView(editText) we can also use TextView instead of editText.
  4. Let the magic happens ;)

Step 1: Install it

How to add to your project

  1. Add to your root build.gradle file:
    allprojects {
        repositories {
            maven { url "" }
  1. Add library to your app build.gradle file then sync
    dependencies {
        implementation 'com.github.joielechong:countrycodepicker:2.4.2'

Step 2: Add to Layout

Add ccp view to xml layout

          android:layout_height="wrap_content" />

If you want to Add EditText view to layout:


Step 4: Show in Activity/Fragment:

Add ccp object in Activity / Fragment

    CountryCodePicker ccp;

Then Bind ccp from layout

    ccp = (CountryCodePicker) findViewById(;

That's it. Run the project and see the results.

If you want to register an EditText with code:

   CountryCodePicker ccp;
   AppCompatEditText edtPhoneNumber;


   ccp = (CountryCodePicker) findViewById(;
   edtPhoneNumber = findViewById(;



You can check validity of phone number using isValid() method.


Here the attributes that can be used in CountryCodePicker layout:

Attribute method Description
ccp_defaultCode setDefaultCountryUsingPhoneCodeAndApply(int defaultCode) set selected Flag and phone in CCP by phone code.
ccp_showFullName showFullName(boolean show) Show full name of country in CCP. Default is false
ccp_hideNameCode hideNameCode(boolean hide) Hide the country name code. Default is false
ccp_hidePhoneCode hidePhoneCode(boolean hide) Hide the phone code. Default is false


Read more here.

## hbb20/AndroidCountryPicker

An android countrypicker library:

Here is the demo screenshot of this library in use:

Step 1. Add dependency

Add in your app/build.gradle:

         dependencies {
           implementation 'com.hbb20:android-country-picker:X.Y.Z'

Step 2: Add to Layout

For the Default Country Picker View add following to your XML layout:

   android:layout_height="wrap_content" />

Step 2: Write Code

Modify view / dialog / list config in activity or fragment:

private fun setupCountryPickerView() {
        val countryPicker = findViewById<CountryPickerView>(

        // Modify CPViewConfig if you need. Access cpViewConfig through `cpViewHelper`
        countryPicker.cpViewHelper.cpViewConfig.viewTextGenerator = { cpCountry: CPCountry ->
            "${} (${cpCountry.alpha2})"
        // make sure to refresh view once view configuration is changed

        // Modify CPDialogConfig if you need. Access cpDialogConfig through `countryPicker.cpViewHelper`
        // countryPicker.cpViewHelper.cpDialogConfig.

        // Modify CPListConfig if you need. Access cpListConfig through `countryPicker.cpViewHelper`
        // countryPicker.cpViewHelper.cpListConfig.

        // Modify CPRowConfig if you need. Access cpRowConfig through `countryPicker.cpViewHelper`
        // countryPicker.cpViewHelper.cpRowConfig.

To Launch Country Picker Dialog add following to your Activity/Fragment:

   context.launchCountryPickerDialog { selectedCountry: CPCountry? ->
     // your code to handle selected country

To Load countries in RecyclerView add following to your Activity/Fragment:

   recyclerView.loadCountries { selectedCountry: CPCountry -> 
     // your code to handle selected country


Read More about Country Picker View and available configuration.