How to create a card toolbar using appcompat v7

Thanks Gabriele for all the help. Here is working code: Activity : public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mai); Toolbar toolbar = (Toolbar) findViewById(R.id.card_toolbar); if (toolbar != null) { // inflate your menu toolbar.inflateMenu(R.menu.main); toolbar.setTitle(“Card Toolbar”); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { return true; } … Read more

Cardview shadow not appearing in lollipop devices?

After going through the docs again, I finally found the solution. Just add card_view:cardUseCompatPadding=”true” to your CardView and shadows will appear on Lollipop devices. What happens is, the content area in a CardView take different sizes on pre-lollipop and lollipop devices. So in lollipop devices the shadow is actually covered by the card so its … Read more

OnClickListener for CardView?

You should implement the OnItemClickListener in your ViewHolder class, and pass the current item to the ViewHolder instances on every onBindViewHolder(). From this post: public static class ViewHolder extends RecyclerView.ViewHolder { public View view; public Item currentItem; public ViewHolder(View v) { super(v); view = v; view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // … Read more