-
-
Notifications
You must be signed in to change notification settings - Fork 506
Use as a Country Selector
Harsh B. Bhakta edited this page Sep 8, 2020
·
3 revisions
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.
All you will need to do is:
- Use full-width layout using
android:layout_width="match_parent"
. - Show full name using
app:ccp_showFullName="true"
. - Remove phone code using
app:ccp_showPhoneCode="false"
. - Remove name code using
app:ccp_showNameCode="false"
. (Optional) - 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.
- Make sure your layout has enough space to accommodate full name.
- How to Integrate into your project
- Full Number Support
- Use as a Country Selector
- Auto detect country
- Auto detect language
- Remember last selection
- Country Preference
- Custom Mater List
- Exclude Countries
- Example phonenumber as hint
- Multi Language Support
- Default Country
- Country Selection Listener
- Dialog events listener
- CCP Theme Customization
- CCP Dialog Theme Customization
- Custom TypeFace
- Read Selected Country
- XML Properties
- Update Guide to v2
- Guide to Add New Language Support
- Guide to add New Country
- Change contry names for local project
- Handle CCP ClickListener Manually
- Custom Dialog Title/Hint/Empty Result ACK
- Flag Emoji Support (BETA)
- Change Log