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.