Skip to content
Fabio Hellmann edited this page Feb 11, 2016 · 4 revisions

WelcomeCard

WelcomeCard is a Card created to provide the same Card that Google uses in some of their apps, such as Google Keep.

It shows a title, a subtitle, a description, a divider, and a button which will dismiss the card.

V3

Card card = new Card.Builder(this)
		.withProvider(new CardProvider())
		.setLayout(R.layout.material_welcome_card_layout)
		.setTitle("Welcome Card")
		.setTitleColor(Color.WHITE)
		.setDescription("I am the description")
		.setDescriptionColor(Color.WHITE)
		.setSubtitle("My subtitle!")
		.setSubtitleColor(Color.WHITE)
		.setBackgroundColor(Color.BLUE)
		.addAction(R.id.ok_button, new WelcomeButtonAction(this)
				.setText("Okay!")
				.setTextColor(Color.WHITE)
				.setListener(new OnActionClickListener() {
					@Override
					public void onActionClicked(View view, Card card) {
						Toast.makeText(mContext, "Welcome!", Toast.LENGTH_SHORT).show();
					}
				}))
		.endConfig()
		.build();

V2 (Deprecated)

For changing title, subtitle, description and button texts, you only need to call the following methods:

WelcomeCard card = new WelcomeCard(context);
card.setTitle("Your title");
card.setSubtitle("My subtitle!");
card.setDescription("Your description");
card.setButtonText("OKAY!");

You will also be able to define the color of every one of the previous attributes, plus the divider and the background colors. Each item offers three ways of defining its color:

  • setXColor(int color), where color is an already resolved Color (Color.parseColor(String color))
  • setXColor(String color), where color is a color expressed in a String, such as "#FF0000"
  • setXColorFromId(Context context, int colorId), where color is a reference to the color, such as R.color.my_color

You only need to replace X for one of the following:

  • Title
  • Subtitle
  • Description
  • Divider
  • ButtonText

By default, the button press triggers a call to the card.dismiss() method, but you could redefine it by calling setOnButtonPressedListener(OnButtonPressListener mListener)