CircleCI Codecov Maven Central Android SDK
Figma Layers Pinterest

CountryPicker

Material design components to pick country.

Download

repositories {
    mavenCentral()
    google()
}
dependencies {
    // base dialogs
    implementation "com.hanggrian.countrypicker:countrypicker:$version"

    // material bottom sheets
    implementation "com.hanggrian.countrypicker:countrypicker-bottomsheet:$version"
}

Usage

Use CountryPickerDialog.Builder to build or show CountryPickerDialog.

new CountryPickerDialog.Builder(context)
    .setOnSelectedListener(new CountryPicker.OnSelectedListener() {
        @Override
        public void onSelected(@NonNull Country country) {
            // do something
        }
    }).show();

Bottom Sheet

No builder here, create traditionally.

BottomSheetDialog dialog = new CountryPickerSheetDialog(context);
dialog.setOnSelectedListener(new CountryPicker.OnSelectedListener() {
    @Override
    public void onSelected(@NonNull Country country) {
        // do something
    }
});
dialog.show();

Custom Flags

To use custom flag images, have a drawable with name format flag_{2-digit iso code} in your project. For example if you want to display US flag, the drawable name should be flag_us.

See Country.java for all available country codes.