I'm attempting to optimize my listitems, when I go into my developer options and turn on "Show Layout Bounds" I noticed that the Gmail app has a completely flat view hierarchy? How is this black magic achieved?
Hierarchy Viewer is a tool built into Android Device Monitor that allows you to measure the layout speed for each view in your layout hierarchy. It can help you find performance bottlenecks caused by the structure of your view hierarchy.
Measurement results: ConstraintLayout is faster As these results show, ConstraintLayout is likely to be more performant than traditional layouts. Moreover, ConstraintLayout has other features that help you build complex and performant layouts, as discussed in the benefits of a ConstraintLayout object section.
LinearLayout is perfect for displaying views in a single row or column. You can add layout_weights to the child views if you need to specify the space distribution. Use a RelativeLayout, or even better a ConstraintLayout, if you need to position views in relation to siblings views or parent views.
One tool that provides excellent data about performance is Systrace, which is built into the Android SDK. The Systrace tool allows you to collect and inspect timing information across an entire Android device, allowing you to see when layout performance problems cause performance problems.
They're likely overriding onDraw and drawing directly to the canvas instead of adding views as children.
http://developer.android.com/training/custom-views/custom-drawing.html
Well, I might be wrong on a few details, but they are using a custom view. A widget, if you want.
Practically, you have a class that extends something, most likely a View, a LinearLayout or a RelativeLayout, than you programmatically add the stuff you need in there and make sure you have methods to acces the stuff from outside, so that when you create a new "thingy", you will be able to give it whatever text or images you want.
In your case, what I would do is a widget that extends LinearLayout and I would add there the image, 3 textViews (name, subject, actual mail) and one more TextView for the date. If you want the star too, that would be one more thing added, an ImageView. You move them around whatever way you want, and that's pretty much it.
If you want some code for that, let me know, I'll give you some more details if you really need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With