Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

Overview

visitors Add

accessibility text

1. Add dependency

  •     dependencies {
          implementation 'com.hbb20:android-country-picker:X.Y.Z'
         }
  • For latest version, Add

2. Decide your use-case

Default Country Picker View i. add following to your XML layout
   <com.hbb20.CountryPickerView
   android:id="@+id/countryPicker"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />

ii. modify view / dialog / list config in activity or fragment

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

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

        // 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.
    }

ii. Read More about Country Picker View and available configuration

Custom Country Picker View

i. Read how to create your Custom Country Picker View

Launch Country Picker Dialog i. add following to your Activity/Fragment
   context.launchCountryPickerDialog { selectedCountry: CPCountry? ->
     // your code to handle selected country
   }

ii. Read More about CountryPicker Dialog and available configuration

Load countries in RecyclerView i. add following to your Activity/Fragment
   recyclerView.loadCountries { selectedCountry: CPCountry -> 
     // your code to handle selected country
   }

ii. Read More about Country List and available configuration

Credits

Comments
  • Adding library messes up with the activity style & show Toolbar by default

    Adding library messes up with the activity style & show Toolbar by default

    I tried adding your library to my Android project:

    implementation("com.hbb20:android-country-picker:0.0.6")
    

    When I run the app, it overrides the activity style & show Toolbar by default!! I am using style with this theme Theme.MaterialComponents.Light.NoActionBar.

    This is the only reason I am not using this library 😞

    opened by RahulSDeshpande 10
  • Country flag

    Country flag

    Hello, I like your library, and I want to use it, but I struggle on how to display a different flag than R.drawable.ic_flag_black.

    I tried to look on how to get the emoji flag, but the issue is also that the getFlag(alpha2Code: String) expect an Int and therefore I don't know how to return the correct flag based on the user selection..

    any help is welcome.

    opened by YSDC 5
  • Set selected country programmatically via alpha2

    Set selected country programmatically via alpha2

    Your CountryCodePickerProject already implements this in the function setCountryForNameCode(String countryNameCode). Would be great to also have it here.

    opened by niglz 1
  • Picker Dialog is not WRAP_CONTENT

    Picker Dialog is not WRAP_CONTENT

    Okay I just realized, so the showFullScreen = false doesn't make the dialog WRAP_CONTENT it's still very large and going until the bottom of the screen even if I have fews countries..

    opened by Dave181295 1
  • How do I change the Dialog title color

    How do I change the Dialog title color

    As I read, I need to create a custom XML for dialog layout But actually need to just change the Title color of the Dialog. Is there any property to override or set?

    opened by AnitCEO 2
Owner
Harsh B. Bhakta
Computer Science Graduate Student
Harsh B. Bhakta
AndroidPhotoFilters aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image media.

PhotoFiltersSDK PhotoFiltersSDK aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image medi

Zomato 2.5k Dec 23, 2022
Android library to display a few images in one ImageView like avatar of group chat. Made by Stfalcon

MultiImageView Library for display a few images in one MultiImageView like avatar of group chat Who we are Need iOS and Android apps, MVP development

Stfalcon LLC 468 Dec 9, 2022
ShimmerTextView is a simple library to integrate shimmer effect in your TextView.

ShimmerTextView ShimmerTextView is a simple library to integrate shimmer effect in your TextView. Key features Set a base color in ShimmerTextView. Se

MindInventory 22 Sep 7, 2022
An easy, flexible way to add a shimmering effect to any view in an Android app.

Shimmer for Android Shimmer is an Android library that provides an easy way to add a shimmer effect to any view in your Android app. It is useful as a

Facebook 5.1k Dec 26, 2022
Dynamic Speedometer and Gauge for Android. amazing, powerful, and multi shape :zap:

SpeedView Dynamic Speedometer, Gauge for Android. amazing, powerful, and multi shape ⚡ , you can change (colors, bar width, shape, text, font ...every

Anas Altair 1.2k Jan 7, 2023
Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API

What is Postman? Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API Usage P

Cafer Mert Ceyhan 129 Dec 24, 2022
Android Rubber Picker Library

RubberPicker RubberPicker library contains the RubberSeekBar and RubberRangePicker, inspired by Cuberto's rubber-range-picker. Getting started Setting

Chrisvin Jem 547 Jan 5, 2023
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022
EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the Etsy app.

EtsyBlur EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the past Etsy app. Try out the sa

Manabu S. 755 Dec 29, 2022
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

Jake Klinker 1.3k Nov 25, 2022
A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix.

SuperForwardView About A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix. GIF Design Credi

Ertugrul 77 Dec 9, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Orbitary ?? Jetpack Compose animation library that allows you to implement animations such as shared element transition. Download Gradle Add the depen

Jaewoong Eum 503 Dec 30, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

?? Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Jaewoong Eum 504 Jan 2, 2023
Allows the easy creation of animated transition effects when the state of Android UI has changed

android-transition Android-Transition allows the easy creation of view transitions that reacts to user inputs. The library is designed to be general e

Kai 615 Nov 14, 2022
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
Chandrasekar Kuppusamy 799 Nov 14, 2022
FilePicker is a small and fast file selector library that is constantly evolving with the goal of rapid integration, high customization, and configurability~

Android File Picker ??️ 中文简体 Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, like its name, is a local file selector fra

null 786 Jan 6, 2023
An simple & awesome animation library written in Kotlin for Android

An simple & awesome animation library written in Kotlin for Android

Romman Sabbir 53 Oct 17, 2022
Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

FabulousFilter Show some ❤️ and star the repo to support the project This library is the implementation of filter-concept posted on MaterialUp.com. It

Krupen Ghetiya 2.6k Jan 3, 2023