Skip to content

Use as a Country Selector

Harsh B. Bhakta edited this page Sep 8, 2020 · 3 revisions

Latest Update

Option 1: Using Android Country Picker library

If you are just looking for a Country Picker then you should consider Android Country Picker library. It is a kotlin-first, flexible and powerful library for Country Picker use case.

Option 2: Using Country Code Picker (this) library

All you will need to do is:

  1. Use full-width layout using android:layout_width="match_parent".
  2. Show full name using app:ccp_showFullName="true".
  3. Remove phone code using app:ccp_showPhoneCode="false".
  4. Remove name code using app:ccp_showNameCode="false". (Optional)
  5. Done! Your country selector / country spinner is ready.
<com.hbb20.CountryCodePicker
   android:id="@+id/ccp"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:ccp_showFullName="true"
   app:ccp_showPhoneCode="false"
   app:ccp_showNameCode="false"/>

this will turn your phone selector into country selector.

By default, the text gravity of the name will be "CENTER". You can change it using app:ccp_textGravity="LEFT" or app:ccp_textGravity="RIGHT".

Now your selection dialog will not show phone code.

Note

  • Make sure your layout has enough space to accommodate full name.
Clone this wiki locally