2

I recently read about CardView for Android.

But, I find myself comfortable using 9 patches as background to get the same effect. It allows me to swap the 9 patch with other images for theming etc.

Can anybody tell me why I should use CardView instead of a proper 9 patch to achieve the same look?

Adinia
  • 3,722
  • 5
  • 40
  • 58
Androbean Studio
  • 382
  • 2
  • 11
  • why is it down voted? ! – Androbean Studio Oct 18 '15 at 10:36
  • 1
    You could do some research; I just searched 'CardView advantage' and found [this answer](http://stackoverflow.com/questions/28794725/advantage-and-disadvantage-of-cardview), it could help you :) – abbath Oct 18 '15 at 10:44
  • @abbath Thanks for responding. But I think the link you gave doesnt answer my question, as to why I shall use cardview instead of a matching 9 patch. – Androbean Studio Oct 18 '15 at 10:56

1 Answers1

0

I prefer to use drawable (XML) as it is simplest. Developers might not love to spend their time in creating 9patch.
Cardview gives you good look by providing you facility to configure radius, elevation etc attributes.

AskQ
  • 4,215
  • 7
  • 34
  • 61
  • Yeah, but you can do the same with a nice shape drawable :) – abbath Oct 18 '15 at 10:47
  • Why to increase images in drawables? Particularly for larger projects.. As it might give you performance hit.. Think of listview having 1000 views whose background is set as 9patch.. Now UI have to render images 1000times!!.. This could make your application heavier – AskQ Oct 18 '15 at 10:51
  • @AskQ If I am right, 9 patches wont add that much load on the memory as they are actually not stretched out as a big bitmap by android. at least with HWUI enabled. I believe its drawn with a 9patch mesh with proper texture coordinates to do the stretching part. So I think 9 patches are still a good way to go provided they can allow theming which Cardview probably cannot. – Androbean Studio Oct 18 '15 at 10:59