4

I created a app with the CardUI libary, but I can't do the things I want to do with the libary. So I decided to recreate it in my own layout. I'm using a listview, with a CustomCursorAdapter which gets a XML layout to put it in the listview. I've seen these cards:

enter image description here

I want that layout of a card to put in a XML file (listview and single_item), but I can't seem to do it. I have a lot of problems with creating this layout in a XML file.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Marc
  • 1,094
  • 3
  • 17
  • 38

1 Answers1

3

To reduce the overdrawing which would (highly probable) result when implementing this as xml, I just took such a screenshot and created a 9.png file for this. Added the 9.png as a background and got the fine looking result I was hoping for.

As long as you don't want some fanzy hanzy special stuff like changing shadows or similar, this is the way I recommend.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • I don't want to do something with changing shadows, but I do want to stretch the card layout at the whole screen, this isn't possible if I take just a screenshot (I think). – Marc May 20 '13 at 17:42
  • With a 9.png (or Nine-Patch) it is possible. Check this: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch (Tool to create/check them: http://developer.android.com/tools/help/draw9patch.html) – WarrenFaith May 20 '13 at 17:45
  • I think that is what I need but I can't get the program working. I did load a .png file of the image above, but I cant delete any pixels or do anything. – Marc May 20 '13 at 17:58
  • The tool is just to show/check the result of the nine patch. You actually need to modify the screenshot in another program like gimp or paint or photoshop. – WarrenFaith May 20 '13 at 18:03
  • Thanks, I really tried to make the image in the program. I'll try it in something else now! – Marc May 20 '13 at 18:06
  • I tried it and I got a working 9 patch image (http://i.imgur.com/zymiro0.png) but it doesn't show up in my item layouts... My single_item layout is made by a RelativeLayout, in the top I said android:background="@drawable/card_background" but even the line (the middle line) doesn't show up. Can you help me? – Marc May 20 '13 at 18:34
  • Paste the complete xml layout with the file in the question and I will take a look... – WarrenFaith May 20 '13 at 19:23
  • I editted it and created it with a top and bottom file. This was much easier and I also can edit it much simpler. Thanks for helping though! – Marc May 20 '13 at 20:49
  • There's also a 9-patch plus .xml + explanation offered online hiere: http://www.tiemenschut.com/simply-get-cards-ui-look/ – TiemenSchut Feb 14 '14 at 12:24