實現一個實際信用卡用戶界面的Android庫:CreditCardView

jopen 9年前發布 | 14K 次閱讀 Android開發 移動開發 CreditCardView

CreditCardView是一個Android庫,它允許開發人員創建能夠復制一個實際的信用卡用戶界面。

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.2’
}

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);

項目主頁:http://www.baiduhome.net/lib/view/home/1435498588903

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!