Skip to content

XML Properties

Harsh B. Bhakta edited this page Mar 18, 2019 · 12 revisions

Here are all the XML properties available for CCP. Scroll down for detailed explanation of each...

<com.hbb20.CountryCodePicker
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	app:ccp_defaultNameCode=“US"
	app:ccp_defaultLanguage="FRENCH"
	app:ccp_contentColor="@color/custom_color"
        app:ccp_arrowColor="@color/custom_arrow_color"
	app:ccp_textSize="20sp"
	app:ccp_arrowSize="20dp"
	app:ccp_customMasterCountries="AD,BT,CL,HT,US,GB,OM,NZ"
	app:ccp_countryPreference="US,NZ"
	app:ccp_flagBorderColor="@color/custom_color"
	app:ccp_textGravity="RIGHT"
	app:ccp_showNameCode="false"
	app:ccp_showFlag="false"
	app:ccp_showFullName="true"
	app:ccp_clickable="true"
	app:ccp_showPhoneCode="false"
	app:ccp_autoDetectCountry="true"
        app:ccp_countryAutoDetectionPref="SIM_ONLY"
	app:ccp_autoDetectLanguage="true"
	app:ccp_autoFormatNumber=“false"
        app:ccp_rememberLastSelection="true"
        app:ccp_selectionMemoryTag="signupCCP"
        app:ccp_showArrow="false"
        app:ccp_hintExampleNumber="true"
        app:ccp_hintExampleNumberType="FIXED_LINE"
        app:ccp_hintExampleNumberFormat="NATIONAL"
        app:ccp_excludedCountries="in,us,pk"
	app:ccpDialog_keyboardAutoPopup="false"
	app:ccpDialog_allowSearch="false"
	app:ccpDialog_showPhoneCode=“false"
	app:ccpDialog_showFastScroller="false"
	app:ccpDialog_fastScroller_bubbleColor="@color/custom_color"
	app:ccpDialog_fastScroller_handleColor="@color/custom_color"
	app:ccpDialog_fastScroller_bubbleTextAppearance="@style/custom_textAppearance"
	app:ccpDialog_backgroundColor="@color/custom_color"
	app:ccpDialog_searchEditTextTint="@color/custom_color"
	app:ccpDialog_textColor="@color/custom_color"
        app:ccpDialog_showCloseIcon="true"
        app:ccpDialog_showFlag="false"
        app:ccpDialog_showTitle="false"
        app:ccpDialog_initialScrollToSelection="true"/>

app:ccp_defaultNameCode="US"

-- This is the country which will be set automatically when layout prepared. If auto_detect_country is enabled, this country will be set in CCP fails to detect country or something goes wrong.

app:ccp_defaultLanguage=“FRENCH" (Default : ENGLISH)

Your specified default language is loaded when layout is prepared. If auto_detect_launguage is enabled, this will be used as fall back language when CCP fails to detect language or detected language is not supported.

app:ccp_contentColor="@color/custom_color"

This will change the color of text and down arrow of CCP view.

app:ccp_arrowColor="@color/custom_arrow_color"

If you want to set arrow color other than content color, set specific arrow color using this property.

app:ccp_textSize=“20sp"

Changes the size of CCP text. It also changes arrowSize accordingly unless explicitly stated using app:ccp_arrowSize.

app:ccp_arrowSize="20dp"

Specifies the size of downward arrow.

app:ccp_customMasterCountries="AD,BT,CL,HT,US,GB,OM,NZ"

Sets specified countries as master countries and will list only those countries to select from. If not specified, all the countries from library will be listed. [Read more]

app:ccp_countryPreference=“US,NZ"

Specified countries will be set as preferred countries and will be listed at the top of countries list. [Read more]

app:ccp_flagBorderColor="@color/custom_color"

If you feel like flags are not properly visible because of matching background color, you can give border color to the flag for better appearance.

app:ccp_textGravity=“RIGHT”

When width is “match_parent”, this will decide the gravity of text in CCP view.

app:ccp_showNameCode=“false" (Default : TRUE)

Decide whether to show name code on CCP. Default : TRUE

app:ccp_showFlag=“false" (Default : TRUE)

Toggles visibility of flag on CCP.

app:ccp_showFullName="true"

To show or hide full name of country on CCP. Default : FALSE

app:ccp_clickable=“false" (Default : TRUE)

Enable / disable click of ccp.

app:ccp_showPhoneCode=“false” (Default : TRUE)

To show or hide phoneCode from CCP. While using CCP as Country selector rather than Phone Code Picker, you want to remove phone code from CCP view. This will affect phone code of CCP_DIALOG unless specified using app:ccpDialog_showPhoneCode.

app:ccp_autoDetectCountry=“true” (Default : FALSE)

If enabled, it will detect country from device and set in CCP as soon as view is rendered. When CCP fails to detect country from device or something goes wrong, it will set your default country (or India, if not specified) as selected country. Read more

If disabled, it will load your specified default country (or India, if not specified) in the CCP when view is prepared.

Before library version 2.1.0, default value was TRUE. That was confusing for many developers

If ccp_rememberLastSelection is enabled, then it might override auto detected country.

app:ccp_countryAutoDetectionPref="SIM_ONLY" (Default : SIM_NETWORK_LOCALE)

This decides how to detect country. Read more

app:ccp_autoDetectLanguage=“true" (Default : FALSE)

If enabled, it will detect device language and load CCP for that language. If CCP fails to detect the language or language is not yet supported, it will switch back to the app:ccp_defaultLanguage.

app:ccp_autoFormatNumber=“false" (Default : TRUE)

Auto formatter will format the number as user types number in registered editText.

app:ccp_rememberLastSelection="true" (Default : FALSE)

Remebers last selection when app is restarted. Read more

app:ccp_selectionMemoryTag="signupCCP"

Tag name to store selection value in shared pref. Read more

app:ccp_showArrow="false" (Default : TRUE)

Set visibility of down arrow on CCP view using app:ccp_showArrow.

app:ccp_hintExampleNumber="true" (Default : FALSE)

When enabled, it will set selected country's example number as the hint of registered carrier number edit text.

app:ccp_hintExampleNumberType="FIXED_LINE" (Default : MOBILE)

This will define type of phone to use as example number.

app:ccp_hintExampleNumberFormat="NATIONAL" (Default : DEFAULT)

If you need hint number in National format with leading 0, this should be set to NATIONAL. Seems like, asYouType formatter by google follows National formats.

app:ccp_excludedCountries="in,us,pk" (Default : NONE)

Using this, developer can exclude specific countries from the selection list. If you have specified your own custom master list using app:ccp_customMasterCountries, then app:ccp_excludedCountries will be ignored.

app:ccpDialog_keyboardAutoPopup="false" (Default : TRUE)

Whether to show keyboard for search as soon as dialog for country selection is launched, is decided by this.

app:ccpDialog_allowSearch=“false" (Default : TRUE)

This will decide whether to allow search from the list of countries. When your custom master list is really short, you might want to remove search option from CCP dialog.

app:ccpDialog_showPhoneCode=“false" (Default : TRUE or follows app:ccp_showPhoneCode when specified)

While using library as Country Selector, you don’t want to show phone code of countries in list. Normally, setting app:ccp_showPhoneCode as false is sufficient to hide phone code from both, CCP and CCP DIALOG as app:ccpDialog_showPhoneCode follows app:ccp_showPhoneCode by default.

app:ccpDialog_showFastScroller=“false" (Default: TRUE)

This enables / disables fastScroller for the CCP Dialog.

app:ccpDialog_fastScroller_bubbleColor=“@color/custom_color"

When fastScroller is enabled, this will be the background color of Index bubble.

app:ccpDialog_fastScroller_handleColor="@color/custom_color"

When fastScroller is enabled, this will be scroller handle color.

app:ccpDialog_fastScroller_bubbleTextAppearance="@style/custom_textAppearance"

This will be the textAppearance for bubble text.

app:ccpDialog_backgroundColor="@color/custom_color"

This### helps you modify theme of the dialog. This will be the background color for the CCP Dialog.

app:ccpDialog_showCloseIcon="true"

If set true, this will add "X" button at top right corner of ccp dialog. Clicking on that button will dismiss the dialog without changing the country selection.

app:ccpDialog_showFlag="false"

If set false, it will remove flag from CCP selection dialog.

app:ccpDialog_showTitle="false"
(Default True)

If set false, it will remove title from the CCP dialog.

app:ccpDialog_initialScrollToSelection="true" (Default False)

Added in version 2.2.3 When set true, ccpDialog will auto scroll to selected country. Note: If selected country is one of the preferred countries then it will not scroll and will show preferred countries from top to avoid user confusion.

Clone this wiki locally