Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to hide country name code ? #60

Closed
zaheerpoei opened this issue Jun 2, 2017 · 30 comments
Closed

how to hide country name code ? #60

zaheerpoei opened this issue Jun 2, 2017 · 30 comments
Labels

Comments

@zaheerpoei
Copy link

i want to show only phone code. there is a method showflag(boolean) that hides the flag if pass false to this. Like wise i want to hide country name code so there left only phone code. so there should be option to hide country code. Please tell me how can i hide country code. Thanks

@hbb20
Copy link
Owner

hbb20 commented Jun 2, 2017 via email

@zaheerpoei
Copy link
Author

thanks brother

@zaheerpoei
Copy link
Author

good work keep it up

@hbb20 hbb20 added the question label Jun 2, 2017
@zaheerpoei
Copy link
Author

can we align the text as centre after selecting value of spinner ??

@hbb20
Copy link
Owner

hbb20 commented Jun 2, 2017 via email

@zaheerpoei
Copy link
Author

after selecting the value from dropdown it shows the selected value in spinner which is left aligned i want to align this to centre. thats it

@hbb20
Copy link
Owner

hbb20 commented Jun 2, 2017 via email

@zaheerpoei
Copy link
Author

screenshot_2017-06-02-12-34-19 1

@hbb20
Copy link
Owner

hbb20 commented Jun 2, 2017 via email

@zaheerpoei
Copy link
Author

<EditText
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="44dp"
    android:layout_alignEnd="@+id/section_label"
    android:layout_alignLeft="@+id/section_label"
    android:layout_alignRight="@+id/section_label"
    android:layout_alignStart="@+id/section_label"
    android:layout_below="@+id/section_label"
    android:layout_marginTop="21dp"
    android:background="@drawable/shape"
    android:ems="10"
    android:padding="10dp"
    android:hint="Enter your first name"
    android:inputType="textPersonName" />


<LinearLayout
    android:id="@+id/l1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@id/editText"
    android:layout_below="@+id/name"
    android:layout_marginTop="24dp"
    android:orientation="horizontal"
    android:background="@drawable/shape"
    android:weightSum="1">

    <com.hbb20.CountryCodePicker
        android:id="@+id/ccp"
        android:layout_width="match_parent"
        android:layout_height="44dp"
        android:layout_weight="0.8"


        app:hideNameCode="true" />


    <EditText
        android:id="@+id/number"
        android:layout_width="match_parent"
        android:layout_height="44dp"
        android:background="@drawable/shape"
        android:layout_weight="0.2"
        android:hint="Enter Your Cell Number"
        android:inputType="phone"
        android:padding="10dp" />
</LinearLayout>


<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="55dp"
    android:layout_marginTop="21dp"
    android:textAllCaps="false"
    android:backgroundTint="?attr/colorPrimary"
    android:text="Next"
    android:textColor="@android:color/white"
    android:layout_below="@+id/l1"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

@hbb20
Copy link
Owner

hbb20 commented Jun 2, 2017

If you want to use weight sum then you should use width = 0. But still this approach is not the best.

Just replace your l1 linear layout with

<RelativeLayout
   android:id="@+id/rl"
   android:layout_width="match_parent"
   android:layout_height="44dp"
   android:layout_below="@+id/name"
   android:layout_marginTop="24dp"
   android:background="@drawable/shape"
   android:layout_alignBottom="@id/editText">

        <RelativeLayout
            android:id="@+id/rl_ccp_holder"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center_vertical">

            <com.hbb20.CountryCodePicker
                android:id="@+id/ccp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                app:hideNameCode="true"
                app:showFlag="false"/>
        </RelativeLayout>

        <EditText
            android:id="@+id/number"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_toRightOf="@+id/rl_ccp_holder"
            android:background="@drawable/shape"
            android:hint="Enter Your Cell Number"
            android:inputType="phone"
            android:padding="10dp"/>
</RelativeLayout>

You will get correct result as per screen shot:
layout-2017-06-02-205318

@hbb20 hbb20 closed this as completed Jun 9, 2017
@MrBrown09
Copy link

MrBrown09 commented Mar 5, 2018

Hi,

Is it possible to restrict some countries not to show in list?

Yes, I got the answer..

app:ccp_customMasterCountries="US,IN,NZ,BD,PL,RO,ZW"

@hbb20
Copy link
Owner

hbb20 commented Mar 5, 2018

Yeah. You got it correct. But I would like to add something here.

Property app:ccp_customMasterCountries is used when you need to include some specific countries. Read More

If you want to exclude just a couple of countries, you should use
app:ccp_excludedCountries. Read more

@josuesantamaria
Copy link

Hi, great library, thanks

Is it possible to hide the flags when you open the modal?

These flags: https://screencast.com/t/DmUzVJWz9

@hbb20
Copy link
Owner

hbb20 commented Jun 20, 2018

@josuesantamaria , this was recently asked on #189.

Currently, there is no option for that. hopefully, we will be releasing new version this weekend with this option. Will that work?

@josuesantamaria
Copy link

It sounds great. Thank you very much.

Also, would be great if we can have more control over the modal UI, like the width of the modal, put lines between the different options, make modal corners rounded. That kind of stuff, but thanks for your very helpful library.

@hbb20
Copy link
Owner

hbb20 commented Jun 24, 2018

Try v2.2.2 and use ccpDialog_showFlag property to hide the flag from dialog.

Regarding your last comment. These requirements are very specific. We might not be able to incorporate it. If you want customized layout simply create a copy of dialog layout with the same name in your layouts directory. You can change style in this copy. Note: do not change/remove id of views. At the run time android will pick your layout file instead of CCP's layout file. Hope this will be helpful.

@josuesantamaria
Copy link

It works perfectly! thank you very much and thanks for the information. Very good job!

@josuesantamaria
Copy link

Hi @hbb20

I followed your advice about creating a copy of dialog layout, I have this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl_holder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/country_code_picker_bg"
    android:padding="8dp">

    <RelativeLayout
        android:id="@+id/rl_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/textView_title"
            android:layout_width="0dp"
            android:layout_height="0dp" />

        <ImageView
            android:id="@+id/img_dismiss"
            android:layout_width="36dp"
            android:layout_height="36dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:alpha="0.7"
            android:background="@drawable/ccp_selectable_bg"
            android:clickable="true"
            android:padding="4dp"
            android:src="@drawable/ic_clear_black_24dp" />

        <RelativeLayout
            android:id="@+id/rl_query_holder"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_toRightOf="@+id/img_dismiss"
            android:layout_toEndOf="@+id/img_dismiss">

            <EditText
                android:id="@+id/editText_search"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/img_clear_query"
                android:layout_toStartOf="@+id/img_clear_query"
                android:hint="@string/country_code_picker_search_hint"
                android:gravity="center"
                android:imeOptions="actionSearch"
                android:singleLine="true"
                android:inputType="textNoSuggestions|textVisiblePassword"
                android:textColor="@android:color/primary_text_light_nodisable" />

            <ImageView
                android:id="@+id/img_clear_query"
                android:layout_width="36dp"
                android:layout_height="36dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:alpha="0.7"
                android:background="@drawable/ccp_selectable_bg"
                android:clickable="true"
                android:padding="10dp"
                android:src="@drawable/ic_backspace_black_24dp" />
        </RelativeLayout>
    </RelativeLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_countryDialog"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/rl_title"
        android:dividerHeight="2dp" />

    <com.futuremind.recyclerviewfastscroll.FastScroller
        android:id="@+id/fastscroll"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/recycler_countryDialog"
        android:layout_alignEnd="@+id/recycler_countryDialog"
        android:layout_alignRight="@+id/recycler_countryDialog"
        android:layout_alignTop="@+id/recycler_countryDialog"
        android:orientation="vertical" />

    <TextView
        android:id="@+id/textView_noresult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rl_title"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"
        android:text="@string/no_result_found"
        android:textColor="@android:color/primary_text_light"
        android:visibility="gone" />

</RelativeLayout>

Like you can see, I just accommodated some fields and changed the editText_search hint value, I also tried to remove the textView_title but it gives me an error and I had to keep it as an empty value.

The problem that I'm facing is that even that I changed the hint value, the text is not updated, it seems that the text is overwritten by some piece of code inside the library, Do you know what is happening? Also, I tried to make a copy of country tile to change the text colors, but again, it seems to be overwritten by another piece of code.

I would appreciate a lot your help

@hbb20
Copy link
Owner

hbb20 commented Jul 4, 2018

  • Hint text is coming from the library because for different languages this will be different.
  • To hide the title, you might wish to use app:ccpDialog_showTitle="false" Read more

Regarding the country tile, I will check and post back.

Do you mind creating a new issue as this part is not alligned with original issue.

@shukla12manish
Copy link

Hi @hbb20
There is a option for flag hiding using

app:showFlag="false"

There is a option for hiding country name code using

app:hideNameCode="true"

But i want to show only flag and selection arrow and hide country code and country name. I am able to hide country name code but not able to hide country code. How can i do it ?

@hbb20
Copy link
Owner

hbb20 commented Mar 2, 2019 via email

@shukla12manish
Copy link

@hbb20 I followed the steps given in this link

https://jitpack.io/p/inpossoft/CountryCodePickerProject

version: 2.0.0

implementation 'com.github.inpossoft:CountryCodePickerProject:2.0.0'

@shukla12manish
Copy link

@hbb20 I think i have used different library. Can you tell me how to add your library into my project step by step, as i tried to add

dependencies {
          implementation 'com.hbb20:ccp:2.2.4'
        }

but it gave me error.

@hbb20
Copy link
Owner

hbb20 commented Mar 3, 2019

For integration, https://github.com/hbb20/CountryCodePickerProject/wiki/How-to-integrate-into-your-project should be helpful. You get some problem integrating that, feel free to comment back. We will be happy to help you with it.

@hbb20
Copy link
Owner

hbb20 commented Mar 3, 2019

Once your setup is complete, use following properties to show only flag.
image

@shukla12manish
Copy link

@hbb20 Hi thanks for the reply but i am still stuck on 3 and 4th step in implementing the library.

Add CCP object in Activity / Fragment
CountryCodePicker ccp;

Bind CCP from layout
ccp = (CountryCodePicker) findViewById(R.id.ccp);

where should i place these codes ?

after adding dependency i synced but android studio showed me

Android resource linking failed

@hbb20
Copy link
Owner

hbb20 commented Mar 4, 2019

Did you remove
implementation 'com.github.inpossoft:CountryCodePickerProject:2.0.0' import?

@m7md7sn994
Copy link

Hi
How to add padding ?

@hbb20
Copy link
Owner

hbb20 commented May 18, 2019

@m7md7sn994 sir, can you please create a new issue with little more explanation about where you want to add padding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants