Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout And Views Visibility on app

I was testing my android app on device by enabling device show layout boundaries in developer option on device.
I check my listview with inflated view with textviews , rating bar and other views clearly seen as shown below . enter image description here

later I tried twitter app but surprise to see only single view ???

enter image description here

anyone know how to get twitter like single view on listview ??

like image 371
Rizvan Avatar asked Nov 02 '22 06:11

Rizvan


1 Answers

anyone know how to get twitter like single view on listview ??

Each list item is a single custom View object, not a ViewGroup or layout. Essentially, all the content is drawn directly onto the Canvas in onDraw() rather than relying on child ImageView and TextView elements. Images can be drawn easily enough by calling Drawable.draw() or Canvas.drawBitmap() and text is typically drawing using a Layout.

Additionally, this means all touch events are handled directly inside onTouchEvent() to handle taps on the lower icons and/or the avatar image, so there are no click listeners.

Edit: Here's a quick 30 second example that should be enough to get you started: https://gist.github.com/devunwired/8704007

enter image description here

like image 89
devunwired Avatar answered Nov 04 '22 09:11

devunwired