Skip to content

Instantly share code, notes, and snippets.

@gabrielemariotti
Created January 14, 2015 23:51
Show Gist options
  • Save gabrielemariotti/10716d3a7c0089f3c034 to your computer and use it in GitHub Desktop.
Save gabrielemariotti/10716d3a7c0089f3c034 to your computer and use it in GitHub Desktop.
How to customize the MaterialLargeImageCard with a own class (requires cardslib 2.1.+)
//Create a Card, set the title over the image and set the thumbnail
CustomMaterialLargeImageCard card = (CustomMaterialLargeImageCard)
CustomMaterialLargeImageCard.with(getActivity())
.setTextOverImage("Italian Beaches "+i)
.setTitle("This is my favorite local beach "+i)
.setSubTitle("A wonderful place")
.useDrawableId(R.drawable.sea)
.setupSupplementalActions(R.layout.carddemo_native_material_supplemental_actions_large, actions)
//It is important to use this build method
.build(new CustomMaterialLargeImageCard(getActivity()));
class CustomMaterialLargeImageCard extends MaterialLargeImageCard {
public CustomMaterialLargeImageCard(Context context) {
super(context);
}
@Override
protected MaterialLargeImageCardThumbnail initializeCardThumbnail() {
//Init your custom Thumbnail
return new CustomMaterialThumbnail(mContext);
}
}
class CustomMaterialThumbnail extends MaterialLargeImageCardThumbnail{
public CustomMaterialThumbnail(Context context) {
super(context);
}
@Override
public void setupInnerViewElements(ViewGroup parent, View imageView) {
//Call the super method
super.setupInnerViewElements(parent, imageView);
//Your code here
mTitleOverImageView = (TextView) parent.findViewById(default_text_id);
mTitleOverImageView.setTextColor(Color.RED);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment