💳 CreditCardView is an Android library that allows developers to create the UI which replicates an actual Credit Card.

Overview

CreditCard View Build Maven Central Android Arsenal

Feature Image

CreditCardView is an Android library that allows developers to create the UI which replicates an actual Credit Card.

Displaying and entering the credit card details inside the app has become a very common use case seen in a lot of different apps, but it is often represented in a not so intuitive manner. With Android Pay being announced at the recent Google I/O 2015, more apps would require users to input their credit card details. I created this library with the aim of making the process of displaying and entering the credit card details more visually appealing to the users of your app.

Screenshots

Screenshots

Features

  • Pre-built card backgrounds to help you get started quickly
  • Fully Customizable
  • Auto selection of drawables based on the credit card number pattern i.e. Visa, Mastercard,American Express & Discover. Will be adding more soon based on the requests I get
  • Auto selection of logo drawable based on the credit card type i.e. Visa, Mastercard and American Express
  • Editable and non-editable mode
  • 4 different card number formats

Setup

The library is pushed to Maven Central as an AAR, so you just need to add the following to your build.gradle file:

dependencies {
    compile ‘com.vinaygaba:creditcardview:1.0.4’
}

Usage

Using CreditCardView is extremely easy, this is how you would declare it in the layout xml:

<!-- Use <com.example.vinay.library.CreditCardView/> if you are using v1.0.1 of the library-->

<com.vinaygaba.creditcardview.CreditCardView
        android:id="@+id/card1"
        android:layout_width="fill_parent"
        android:layout_height="225dp"
        android:background="@drawable/cardbackground_world"
        android:layout_marginBottom="16dp"
        android:layout_marginTop="16dp"
        app:cardNumber="5500005555555559"
        app:cardName="Vinay Gaba"
        app:cardNumberTextColor="#cccccc"
        app:cardNumberFormat="masked_all_but_last_four"
        app:cardNameTextColor="#cccccc"
        app:type="auto"
        app:brandLogo="@drawable/brandlogo"
        app:putChip="true"
        app:expiryDate = "02/22"
        app:expiryDateTextColor="#cccccc"
        app:isEditable="true"
        app:validTillTextColor="#cccccc"
        app:hintTextColor = "#cccccc"
        />

Remember to put this for custom attribute usage:

xmlns:app="http://schemas.android.com/apk/res-auto"

And this is how you would be adding it programatically in java:

CreditCardView creditCardView= new CreditCardView(this);

OR

CreditCardView creditCardView= (CreditCardView)findViewById(R.id.ID_OF_CARD);

Attribute Usage & Documentation

Attribute Description

I) android:background

Use this attribute to set the background of the card. This library includes 3 background by default which you can use, but feel free to put any drawable and use it as the card background as you please. If you do not want to use your own drawable and want to use the drawables available in the screenshots, do the following:

1)Sky Background

Sky

To use this background,simply use the line:

android:background = "@drawable/cardbackground_sky"

2)World Background

World

To use this background,simply use the following line:

android:background = "@drawable/cardbackground_world"
  1. Plain Background

Plain

This is a customizable plain background where you can change the background color, radius and border color of the card. To use this, add the folowing line:

android:background = "@drawable/cardbackground_plain"

To customize the corner radius of the card, add the following attribute to your dimen.xml file with the attribute name "card_corner_radius":

<dimen name="card_corner_radius">size_in_dip</dimen>      //Default value is 10dip

To customize the background color and the border color of this card, add the following attributes to your color.xml file:

<color name="card_background">color_value</color>        //Default value is #e5e5e5
<color name="card_border">color_value</color>            //Default value is #ffffff

The important thing to note is that the name of these items should remain the same.

4)Custom Background

You can essentaially set any background you want as the card background. You can set the value in xml using:

android:background="@drawable/drawable_name"

You can set the value of this attribute programmatically using:

//Set Card Background
creditCardView.setBackgroundResource(R.drawable.drawable_name);
II) app:isEditable

Use this attribute if you want to make the card number, card name and the expiry date field editable to the user.

Editable Gif

You can set the value in xml using:

app:isEditable="true/false"

You can set the value of this attribute programmatically using:

//Set Is Editable Value
creditCardView.setIsEditable(true/false);

//Get Is Editable Value 
boolean isEditable= crediCardView.getIsEditable();

If you are using v1.0.3 and above, there are additional attributes that give you a more granular control over fields. They are: app:isCardNumberEditable , app:isCardNameEditable & app:isExpiryDateEditable

They have precedence over the isEditable attribute i.e. If these attributes are present, the respective fields will take their value over the value present in isEditable attribute

Note: The card type auto detection and space after every 4 letters is added as soon as the focus is shifted from the edit field

III) app:cardNumber

Use this attribute to set the card number of the card.

You can set the value in xml using:

app:cardNumber="1234567890123456"

You can set and get the value of this attribute programmatically using:

//Set Card Number
crediCardView.setCardNumber("1234567890123456");

//Get Card Number
String cardNumber = crediCardView.getCardNumber();
IV) app:cardNumberTextColor

Use this attribute to set the text color of card number attribute.

You can set the value in xml using:

app:cardNumberTextColor="#ffffff"

You can set and get the value of this attribute programmatically using:

//Set Card Number Text Color
creditCardView.setCardNumberTextColor(Color.WHITE);

//Get Card Number Text Color
int color = crediCardView.getCardNumberTextColor();
V) app:cardNumberFormat

Use this attribute to set the card number format of card number. There are four different formats supported by the library:

Card number Format Image

  1. all_digits - This will display all the numbers of the card number.
  2. masked_all_but_last_four - This will mask all the digits except the last four of the card number.
  3. only_last_four - This will display only the last four digits of the card number.
  4. masked_all - This will mask all the digits of the card number.

You can set the value in xml using:

app:cardNumberFormat="all_digits/masked_all_but_last_four/only_last_four/masked_all"    //Use any one format type

You can set and get the value of this attribute programmatically using:

//Set Card Number Format. Chooose any one format
creditCardView.setCardNumberFormat(CardNumberFormat.ALL_DIGITS/CardNumberFormat.MASKED_ALL_BUT_LAST_FOUR/CardNumberFormat.ONLY_LAST_FOUR/CardNumberFormat.MASKED_ALL);

//Get Card Number Format
int cardFormat = crediCardView.getCardNumberFormat();

Note: Default value is all_digits

VI) app:cardName

Use this attribute to set the card name of the card.

You can set the value in xml using:

app:cardName="John Doe"

You can set and get the value of this attribute programmatically using:

//Set Card Name
crediCardView.setCardName("John Doe");

//Get Card Name
String cardName = crediCardView.getCardName();
VII) app:cardNameTextColor

Use this attribute to set the text color of card name attribute.

You can set the value in xml using:

app:cardNameTextColor="#ffffff"

You can set and get the value of this attribute programmatically using:

//Set Card Name Text Color
creditCardView.setCardNameTextColor(Color.WHITE);

//Get Card Name Text Color
int color = crediCardView.getCardNamerTextColor();
VIII) app:expiryDate

Use this attribute to set the expiry date of the card in MM/YY or MM/YYYY format.

You can set the value in xml using:

app:expiryDate="01/15"

You can set and get the value of this attribute programmatically using:

//Set Expiry Date
crediCardView.setExpiryDate("01/15");

//Get Card Number
String expiryDate = crediCardView.ExpiryDate();
IX) app:expiryDateTextColor

Use this attribute to set the text color of expiry date attribute.

You can set the value in xml using:

app:expiryDateTextColor="#ffffff"

You can set and get the value of this attribute programmatically using:

//Set Expiry Date Text Color
creditCardView.setExpiryDateTextColor(Color.WHITE);

//Get Expiry Date Text Color
int color = crediCardView.getExpiryDateTextColor();
X) app:putChip

Use this attribute if you want the card to display the chip on the card.

Put Chip

You can set the value in xml using:

app:putChip="true/false"

You can set the value of this attribute programmatically using:

//Set Put Chip Value
creditCardView.putChip(true/false);
XI) app:type

Use this attribute to set the type of the credit card. The library automatically places the corresponding drawable in the bottom right corner based on the type you have selected. Currectly there are 5 different types supported:

  1. visa
  2. mastercard
  3. american_express
  4. discover
  5. auto - Use auto if u want the library to automatically choose the card type based on the card number you have entered. To know more about the patterns for identifying the card type from the card number, see this link

You can set the value in xml using:

app:type="visa/mastercard/american_express/discover/auto"

You can set the value of this attribute programmatically using:

//Set Card Type.Choose any one card type from the following
creditCardView.setType(CardType.VISA/CardType.MASTERCARD/CardType.AMERICAN_EXPRESS/CardType.DISCOVER/CardType.AUTO);

//Get Card Type. 
int type = crediCardView.getType();
XII) app:brandLogo

Use this attribute to set the brand logo drawable that you see in the upper right corner.

You can set the value in xml using:

app:brandLogo="@drawable/drawable_name"

You can set and get the value of this attribute programmatically using:

//Set Brand Logo
crediCardView.setBrandLogo(R.drawable.drawable_name);

If you wish to modify the default dimensions of the brand logo, add the following attribute to your dimen.xml file:

<dimen name="brand_logo_width">size_in_dp</dimen>    //Default value is 120dp
<dimen name="brand_logo_height">size_in_dp</dimen>   //Default value is 40dp

The important thing to note is that the name of these items should remain the same.

XIII) app:hintTextColor

Use this attribute to set the hint text color that is visible when card name, card number and expiry date fields are editable and blank

You can set the value in xml using:

app:hintTextColor="color_value"    //Default is White

You can set and get the value of this attribute programmatically using:

//Set Hint Text Color
crediCardView.setHintTextColor(color_value);

//Get Hint Text Color
int color = crediCardView.geHintTextColor();

Additional Customizations

My aim with this library was to cover as many use cases as possible and so I have tried to make it extremely customizable. There are some additional customizations possible like:

I) Modify String Resources

You can modify the hints which are displayed when the fields are empty and the card is editable. You can modify those by adding these attributes in the strings.xml file:

<string name="card_number_hint">hint</string>        //Default value: "ENTER CARD NUMBER"
<string name="expiry_date_hint">hint</string>        //Default value:"MM/YY"
<string name="card_name_hint">hint</string>          //Default value: "ENTER CARD NAME"

You can also modify some other additional string resources like:

<string name="valid_till">string</string>           //Default value: "VALID TILL"

The important thing to note is that the name of these items should remain the same. Please make sure the string resources are in caps to be displayed correctly as the font does not support lower case

II) Modify Dimensions

You can modify the dimensions of some of the attributes by adding these attributes to your dimens.xml file:

<dimen name="card_number_text_size">size</dimen>        //Default value:16sp
<dimen name="card_name_text_size">size</dimen>          //Default value:14sp
<dimen name="expiry_date_text_size">size</dimen>        //Default value:14sp
<dimen name="valid_till_text_size">size</dimen>         //Default value:10sp
<dimen name="brand_logo_width">size</dimen>             //Default value:120dp
<dimen name="brand_logo_height">size</dimen>            //Default value:40dp

The important thing to note is that the name of these items should remain the same.

Contributing

Please use the issue tracker to report any bugs or file feature requests. There are a few features that I plan to work on based on the response the library gets, some of them being:

  • Tablet Optimization. The current version is not optimized for tablets
  • Landscape Optimization. The current version is not optimized for landscape mode
  • Credit Card back view to display the CVV number
  • Animations and touch callbacks
  • Stack View to display multiple cards

I would love to get more people involved in the development of this library. A lot of times people are not sure about how they should be contributing to open source. If you are one of them, this is a great opportunity for you to get involved. You can also reach out to me for any queries that you might have about this library.

Credits

Author: Vinay Gaba ([email protected])

Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 Vinay Gaba

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Implemented flip view animation on CreditCardView

    Implemented flip view animation on CreditCardView

    • Updated .gitignore *Changed package name in sample to correct package name in build.gradle *Implemented flip animation for CreditCardView. Library will now require NineOldAndroids
    opened by GregSaintJean 31
  • Card doesn't render properly when programatically setting card number etc.

    Card doesn't render properly when programatically setting card number etc.

    I'm using the card view in a list. In the list adapter's getView, I findViewById for the credit card view and then I set card number, name and expiry.

    The following scenarios happen:

    1. If the card isn't editable, nothing appears in the fields.
    2. If the card is editable, I can tap in the card number field and then my card number appears.
    3. If I remove the programmatic calls to setCardNumber etc and hardcode the number, name and expiry in the layout xml, the card renders correctly.
    bug 
    opened by biddster 22
  • Add CVV field.

    Add CVV field.

    It would be nice to have a cvv field in the card. I was thinking of sending a pr, but I need your opinion about the placement.

    • It should be at rightOf the expiryDate
    • It should be at rightOf the expiryDate. But validTill & expiryDate are leftAligned as well.
    • It should be at rightOf the cardName
    enhancement 
    opened by vijayrawatsan 14
  • State change listener

    State change listener

    It would be great if we could have some kind of state change listener which fires after all of the CreditCardView's internal text changed processing has taken place.

    This would allow client code to update models and validate the current state of the card entry (i.e. valid enables a button).

    enhancement 
    opened by biddster 11
  • NPE on blur if no card number entered

    NPE on blur if no card number entered

    I have the credit card setup to be blank so a user can input a new card. If I click in the credit card field and then click out without entering a number, I get this exception:

    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                at com.vinaygaba.creditcardview.CreditCardView$2.onFocusChange(CreditCardView.java:215)
                at android.view.View.onFocusChanged(View.java:5206)
                at android.widget.TextView.onFocusChanged(TextView.java:7913)
                at android.view.View.clearFocusInternal(View.java:5089)
                at android.view.View.unFocus(View.java:5122)
                at android.view.ViewGroup.requestChildFocus(ViewGroup.java:658)
                at android.view.View.handleFocusGainInternal(View.java:4955)
                at android.view.View.requestFocusNoSearch(View.java:7678)
                at android.view.View.requestFocus(View.java:7657)
                at android.view.View.requestFocus(View.java:7624)
                at android.view.View.requestFocus(View.java:7603)
                at android.view.View.onTouchEvent(View.java:9439)
                at android.widget.TextView.onTouchEvent(TextView.java:7965)
                at android.view.View.dispatchTouchEvent(View.java:8471)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
                at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
                at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
                at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
                at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
                at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
                at android.view.View.dispatchPointerEvent(View.java:8666)
                at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
                at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
                at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
                at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
                at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
                at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
                at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
                at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
                at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
                at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
                at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
                at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
                at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
                at android.view.ViewRootImpl.deliverInputEvent(Vi
    
    
    bug 
    opened by biddster 11
  • More granular control over editable state

    More granular control over editable state

    I'd really like to see the editable state being applied to individual fields rather than the card as a whole.

    E.g. Our app only allows users to update expiry of cards once created.

    enhancement 
    opened by biddster 8
  • Preview in Android Studio has rendering problems

    Preview in Android Studio has rendering problems

    I've added the credit card to one of my fragments. When I select the design view for that fragment I get the following exception:

    java.lang.RuntimeException: Font asset not found fonts/creditcard2.ttf
        at android.graphics.Typeface.createFromAsset(Typeface.java:190)
        at com.vinaygaba.creditcardview.CreditCardView.init(CreditCardView.java:73)
        at com.vinaygaba.creditcardview.CreditCardView.<init>(CreditCardView.java:59)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:437)
        at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:154)
        at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:93)
        at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:190)
        at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
        at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
        at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
        at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
        at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:410)
        at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)
        at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
        at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:511)
        at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:499)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
        at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:499)
        at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
        at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:611)
        at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:608)
        at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:364)
        at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:608)
        at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:630)
        at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
        at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
        at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
        at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
        at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
        at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
        at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
        at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
        at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:695)
    
    
    bug help wanted 
    opened by biddster 7
  • creditcard.ttf and creditcard2.ttf are not redistributable

    creditcard.ttf and creditcard2.ttf are not redistributable

    These files are located here: https://github.com/vinaygaba/CreditCardView/tree/master/library/src/main/assets/fonts

    This typeface was created by and is available under license from K-Type: http://www.k-type.com/fonts/credit-card/

    Their license terms do not permit redistribution in open-source projects: http://www.k-type.com/licences/

    bug 
    opened by tadfisher 7
  • Can't use with RecyclerView

    Can't use with RecyclerView

    I use CreditCardView as an item layout xml for using in RecyclerView but I can't set data by using code :( Can you check it please? I waste all day for it :( Thank you so much

    public class CreditCardViewAdapter extends RecyclerView.Adapter<CreditCardViewAdapter.CreditViewHolder> {
    
        private Context context;
        private List<PaymentAccount> paymentAccountList;
    
        public CreditCardViewAdapter(Context context, List<PaymentAccount> paymentAccountList) {
            this.context = context;
            this.paymentAccountList = paymentAccountList;
        }
    
        @Override
        public CreditViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View itemView = LayoutInflater
                    .from(parent.getContext())
                    .inflate(R.layout.item_credit_card, parent, false);
    
            return new CreditViewHolder(itemView);
        }
    
        @Override
        public void onBindViewHolder(CreditViewHolder holder, int position) {
            PaymentAccount paymentAccount = paymentAccountList.get(position);
            holder.setPaymentAccount(paymentAccount);
        }
    
        @Override
        public int getItemCount() {
            return paymentAccountList.size();
        }
    
        public class CreditViewHolder extends RecyclerView.ViewHolder {
    
            protected CreditCardView creditCardView;
            protected PaymentAccount paymentAccount;
    
            public CreditViewHolder(View itemView) {
                super(itemView);
                creditCardView = (CreditCardView) itemView.findViewById(R.id.cv_credit_card);
            }
    
            public void setPaymentAccount(PaymentAccount paymentAccount) {
                this.paymentAccount = paymentAccount;
    
                creditCardView.setCardNumber(this.paymentAccount.getNumber());
                creditCardView.setExpiryDate(this.paymentAccount.getExpireMonth() + "/" + this.paymentAccount.getExpireYear());
                creditCardView.setCardName(this.paymentAccount.getFirstName() + " " + this.paymentAccount.getLastName());
            }
        }
    }
    
    duplicate 
    opened by nambv 6
  • 1.0.3 declared but getting code inconsistent with (older than) release commit

    1.0.3 declared but getting code inconsistent with (older than) release commit

    It's all in the title. I have jitpack declared as the very first repo to look in for dependencies, I've cleared every possible cache, and yet I still get a jar of the library that has old code -- even though the jar has 1.0.3 in the name, things like programmatic setters do not update the views.

    opened by josefdlange 2
  • Can't set plain background on Android 4.2

    Can't set plain background on Android 4.2

    Hi,

    I want a plain color background on the view. I set this:

    android:background = "@drawable/cardbackground_plain"
    
    <color name="card_background">#0060E2</color>
    

    Works on Android 8, but fail on Android 4.2.2

    Android 8 -> Image Android 4.2.2 -> Image

    How can i solve it?

    Thanks

    opened by javichaques 1
  • you have a problem with crediCardView.getCardNumber();

    you have a problem with crediCardView.getCardNumber();

    cant find "crediCardView" Even when i make the correct spelling of by adding the 'T' to make it "creditcardview", it still cant find that class

    opened by Samuelincoom 0
  • Change card programmatically not work in DialogFragment

    Change card programmatically not work in DialogFragment

    I have dialog fragment which saves/sets the creditcard information programmatically. Everything works ok but the show the saved creditcard info. I'm using this line of code to set creditcard programmtically:

    creditCardView.setExpiryDate(expdate);
    creditCardView.setCardNumber(creditCard.number);
    

    I think the problem is that you dont reset the text of your expiryDate and cardNumber, just call the function invalidate(); to redraw the view.

    opened by kingfisherphuoc 1
  • passing value into card programmatically

    passing value into card programmatically

    This setCardName function is not working

    CreditCardView creditCardView = (CreditCardView) findViewById(R.id.custom_card_image);
    creditCardView.setCardName("Burak");
    
    opened by bkmalkoc 10
Releases(v1.0.3)
  • v1.0.3(Jul 9, 2015)

    -More granular control over editable fields Created new attributes like isCardNumberEditable,isCardNameEditable & isExpiryDateEditable to give you more control over the editable property of these fields

    -Fixed Android Studio Layout Editor Preview Issue

    -Fixed Issue on Fields Not Rendering When Set Programatically

    -Code Formatting (Courtesy: @VenomVendor)

    -Other misc. bug fixes

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jun 23, 2015)

    -Changed package name to com.vinaygaba.credditcardview Use this package "com.vinaygaba.credditcardview" in your views if you are using the latest version.

    -Fixed documentation errors in the readme file

    -Change font to Halter which is free to use and made the corresponding changes to the font size

    Source code(tar.gz)
    Source code(zip)
Owner
Vinay Gaba
Google Developer Expert for Android Senior Software Engineer @airbnb 🏠 Previously @Snapchat 👻 @spotify 🎵 @Deloitte 🤵
Vinay Gaba
Rn-scratch-card - React Native Scratch Card which temporarily hides content from user

rn-scratch-card React Native Scratch Card which temporarily hides content from a

Sweatcoin 54 Jan 4, 2023
Una aplicación para visualizar el catalogo de peliculas actual.

FILMY es una aplicación destinada a dispositivos móviles Android, donde el usuario puede observar todas las películas lanzadas hasta el momento siendo

Jeremias Schneider 3 Jun 6, 2022
Android Library to build a UI Card

Card Library Travis master: Travis dev: Card Library provides an easy way to display a UI Card using the Official Google CardView in your Android app.

Gabriele Mariotti 4.7k Dec 29, 2022
Android Card-Library

Android Card-Library Technology Stack Android Studio Bumblebe

Eraño Payawal 7 Jul 28, 2022
Android view that allows the user to create drawings. Customize settings like color, width or tools. Undo or redo actions. Zoom into DrawView and add a background.

DrawView Android view that allows the user to create drawings. Draw anything you like in your Android device from simple view. Customize draw settings

Oscar Gilberto Medina Cruz 839 Dec 28, 2022
The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months

Custom-Calendar-View To use the CustomCalendarView in your application, you first need to add the library to your application. You can do this by eith

Nilanchala Panigrahy 113 Nov 29, 2022
This is a android custom view , like a scratch card effect!

ScratchView This is a android custom view , like a scratch card effect! Last Update 采纳DearZack童鞋的优化思路,把计算擦除面积比例的操作放在手指离开屏幕时,以降低对CPU的占用。 Articles Scrat

D_clock爱吃葱花 316 Nov 29, 2022
Android App to Teach the Card Counting Skill

card-counting Android App to Teach the Card Counting Skill. The skill can be used to make more informed decisions while playing games like Blackjack.

Jamie Flynn 1 Dec 30, 2021
Simple card app for Udacity's Android Basics: User Interface course

just-because-card Simple card app for Udacity's Android Basics: User Interface c

null 0 Jan 6, 2022
A tinder like swipeable card stack component

AndroidSwipeableCardStack Change log: provide option to infinitly swipe in a loop card rotation setting card gravity setting undo animation Thanks for

wenchao jiang 824 Nov 10, 2022
A simple implementation of swipe card like StreetView

A simple implementation of swipe card like StreetView!! DONATIONS This project needs you! If you would like to support this project's further developm

Michele Lacorte 831 Jan 4, 2023
Created a Tinder like Card Deck & Captain Train like Toolbar

TinderView Created A Simple and Beautiful Tinder like card deck & Captain Train like toolbar. This is heavily based on AndroidSwipeableCardStack, wenc

Aradh Pillai 328 Jun 18, 2022
PCard Add payment card screen made using JetPack Compose

PCard Add payment card screen made using JetPack Compose Find this repository useful? ❤️ Support it by joining stargazers for this repository. ⭐ And f

Mohamed Elbehiry 61 Dec 16, 2022
Card with swipe options in Jetpack Compose

SwipeableActionCard Card with swipe options in Jetpack Compose Tutorial: Click Here Import SwipeableActionCard library Add this in project level build

Harsh Mahajan 1 Nov 23, 2021
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

Jake Klinker 1.3k Nov 25, 2022
IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts.

IconicDroid IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts. Try out the sample application on the Googl

Artur Termenji 387 Nov 20, 2022
We are not Gif makers, We are developers

We are not Gif makers, We are developers Recently me and my friend came across this downloading animation on Dribble: https://dribbble.com/shots/18878

Thibault Guégan 1.7k Nov 28, 2022
Custom Lean back adaper for tv developers

CustomLeanBackAdapter Custom Lean back adaper for tv developers Installation: Add in root gradle: allprojects { repositories { maven { url

null 0 May 16, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Dec 6, 2022