I've had this issue myself, and I was able to solve it very easily.
There isn't too much documentation about it, which is disappointing.
Since the Card class is deprecated and the CardBuilder.EMBED_INSIDE is fairly limited. The only option you have is to use a custom View, as was mentioned before. But you don't need to manually inflate it!
If you use are using the CardScrollView and the CardScrollAdapter. You can do the following in your Activity:
private CardScrollView _cardScroller;
private ArrayList<View> _cardsList;
private MyCustomView _myView;
@Override
protected void onCreate(Bundle bundle) {
_cardsList = new ArrayList<View>();
_myView= new MyCustomView (this);
_cardsList.add(_myView);
_cardScroller = new CardScrollView(this) ;
MainCardsScrollAdapter adapter = new MainCardsScrollAdapter(_cardsList);
_cardScroller.setAdapter(adapter);
_cardScroller.activate();
setContentView(_cardScroller);
}
Now I used a custom CardScrollAdapter because now it has views instead of CardBuilders:
public class MainCardsScrollAdapter extends CardScrollAdapter
{
ArrayList<View> _cardsList;
public MainCardsScrollAdapter(ArrayList<View> cardsList)
{
_cardsList = cardsList;
}
@Override
public int getCount() {
return _cardsList.size();
}
@Override
public Object getItem(int i) {
return _cardsList.get(i);
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
return _cardsList.get(i);
}
@Override
public int getPosition(Object o) {
return _cardsList.indexOf(o);
}
@Override
public int getViewTypeCount() {
return CardBuilder.getViewTypeCount();
}
@Override
public int getItemViewType(int position){
return 0;//should be changed, it's just an example
}
}
Now simply create a layout that you want in an xml.
And create your custom view:
public class MyCustomView extends FrameLayout{
public MyCustomView (Context context) {
super(context);
initView();
}
private void initView()
{
View view = inflate(getContext(), R.layout.live_card, null);
addView(view);
}
}
You can add as many custom views as you like.
I hope it helps