CardsUI View Library
Google’s Now popular Cards UI has everyone in the Android design community excited, including myself.
I developed this for a project I’m working on, and decided to make it abstract and upload it as a library.
You can download the example APK here, or just Clone the library from Bitbucket or from Github, including the example’s app source code and the library’s source code.
It took me a while to get the code together. The view might still be a little flaky from time to time, and the View’s code is NOT well documented, but the example really shows you how simple it is.
Feel welcome to modify any of the code, fork it and pull it.
Layout XML:
|
1 2 3 4 5 6 7 8 9 10 11 |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <com.fima.cardsui.views.CardUI android:id="@+id/cardsview" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> |
Activity Class:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// init CardView mCardView = (CardUI) findViewById(R.id.cardsview); mCardView.setSwipeable(false); // add AndroidViews Cards mCardView.addCard(new MyCard("Get the CardsUI view")); mCardView.addCardToLastStack(new MyCard("for Android at")); MyCard androidViewsCard = new MyCard("www.androidviews.net"); androidViewsCard.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.androidviews.net/")); startActivity(intent); } }); mCardView.addCardToLastStack(androidViewsCard); // add one card, and then add another one to the last stack. mCardView.addCard(new MyCard("2 cards")); mCardView.addCardToLastStack(new MyCard("2 cards")); // add one card mCardView.addCard(new MyCard("1 card")); // create a stack CardStack stack = new CardStack(); stack.setTitle("title test"); // add 3 cards to stack stack.add(new MyCard("3 cards")); stack.add(new MyCard("3 cards")); stack.add(new MyCard("3 cards")); // add stack to cardView mCardView.addStack(stack); // draw cards mCardView.refresh(); |








