Skip to main content

Posts

Showing posts with the label demo

Google I/O 2014: Rehash

All of the videos have been posted from the various sessions I was in this year. Here they are, along with links to the slides. What's new in Android A presentation with  +Dan Sandler  that provides a quick overview of some of the larger features and new APIs in the L Developer Preview release and other new bits in the recent Androidosphere. There's also a really good deep-dive into Notifications, since Dan's the non-local expert on the subject. Slides (PDF) Material science This session, presented with  +Adam Powell , provides an overview of the engineering side of the Material design system. Many of the other sessions at Google I/O this year discussed the design side; this presentation covers the technical details of the APIs and the capabilities exposed by the framework for Android developers. Slides (PDF) Material witness I was happy to be joined once again by former Android developer and UI Toolkit team lead  +Romain Guy  for this talk on some of the new Ma...

Lazy Lists

Let's talk about laziness. No, let's not just talk about being lazy - let's do something about it. Let's be lazy. There's a common pattern that I use in Android programming where I will create objects lazily, especially when these objects will not necessarily or frequently be needed at runtime. This is especially true for code that I write for the Android framework, where we like to be as lean as possible and leave more memory available for the system and the application. Often, these objects are collections. My personal favorite is ArrayList (ever since I moved on years ago from the original, but somewhat crusty,  Vector class), although I am also known to use Hashmap for those key/value pair situations (especially after I got used to ActionScript's paradigm of everything-is-a-hashmap). Of course, you can't simply start poking into a lazily-created collection willy-nilly, unless you're a big fan of NullPointerExceptions. So you need to first check ...

DevBytes: Squash & Stretch

Cartoon animation uses a technique called "squash & stretch" for achieving different effects of objects interacting with their environment. This episode shows how we can use similar techniques to get more organic and lively animations in user interfaces. This and other cartoon animation techniques were discussed in the talk A Moving Experience at Google I/O 2013. Code: http://developer.android.com/shareables/devbytes/SquashAndStretch.zip YouTube: https://www.youtube.com/watch?v=wJL1oW6DlCc Or, in illustrated form:

DevBytes: Anticipation & Overshoot, Part 2

Like my previous DevBytes episode, Anticipation and Overshoot, Part I ," this episode covers cartoon animation techniques for making UI elements more engaging and playful. The code in this episode shows how to change and animate how a button is drawn to make it seem more alive and organic. This and other cartoon animation techniques were discussed in the talk A Moving Experience at Google I/O 2013. Code: http://developer.android.com/shareables/devbytes/Anticipation.zip YouTube: DevBytes: Anticipation and Overshoot - Part 2

DevBytes: Anticipation and Overshoot, Part 1

Some principles of cartoon animation can be used to provide more engaging and more interactive experiences in applications. This episode demonstrates principles of anticipation and overshoot with a simple button click, showing how to animate changes in the button's appearance to make it interact more playfully with the user. This and other cartoon animation techniques were discussed in the talk A Moving Experience at Google I/O 2013 Code: http://developer.android.com/shareables/devbytes/LiveButton.zip YouTube: https://www.youtube.com/watch?v=uQ7PTe7QMQM

DevBytes: Curved Motion

This is a demo that +Romain Guy and I showed in our A Moving Experience talk at Google I/O this year, showing how to use the existing TypeEvaluator and Animator APIs to get curved motion for your animations. In the real world, things don't move in straight lines. Moving items around on the screen should feel as natural as possible; sometimes curved motion can help. This episode shows how to use the existing animation APIs to get easy curved motion for your UIs. The helper classes come from an article I posted on my blog last year: http://graphics-geek.blogspot.com/2012/01/curved-motion-in-android.html YouTube: https://www.youtube.com/watch?v=JVGg4zPRHNE Code: http://developer.android.com/shareables/devbytes/CurvedMotion.zip

DevBytes: Animating Multiple Properties in Parallel

Suppose you want to animate multiple properties in parallel on some target object. How would you do it? ValueAnimator? Multiple ObjectAnimators? This episode covers different ways of animating multiple properties, and specifically covers the use of the lesser-known PropertyValuesHolder class. YouTube: https://www.youtube.com/watch?v=WvCZcy3WGP4 Code: http://developer.android.com/shareables/devbytes/MultiPropertyAnimations.zip

DevBytes: Animating ListView Deletion: Now on Gingerbread!

In this episode, I tried to anticipate the question I knew would come up on my previous show about animating ListView deletion: "But how would I do this on Gingerbread?" Here's how. YouTube: https://www.youtube.com/watch?v=PeuVuoa13S8&list=PLWz5rJ2EKKc_XOgcRukSoKKjewFJZrKV0&index=1 Code: http://developer.android.com/shareables/devbytes/ListViewItemAnimations.zip

DevBytes: Custom Activity Animations

It's Friday: time for another DevBytes. It's been a while, but they're back. At least until the queue runs out again and I write another glut of demos to talk about. This episode, and most of the upcoming ones (teaser alert!) are around demos/code that we showed in A Moving Experience, the animation talk that +Romain Guy and I gave at Google I/O 2013. Custom Activity Animations : Window animations provide an easy way to animate transitions between activities. The animations can be customized to some extent, but there's only so much interaction between the launching and launched activities that you can take advantage of with the standard window animations. This episode covers a different technique for fully customizable animations. Video: http://www.youtube.com/watch?v=CPxkoe2MraA Code: http://developer.android.com/shareables/devbytes/ActivityAnimations.zip

DevBytes: Layout Transitions

The LayoutTransition class (added in Android 3.0) enables easy fade/move/resize animations when items are added to or removed from a ViewGroup, usually with just one line of code. This video shows how this works and also shows the new ability added in JellyBean (Android 4.1) to animate other changes to the layout as well, not limited to items being added or removed. YouTube: https://www.youtube.com/watch?v=55wLsaWpQ4g Code: http://developer.android.com/shareables/devbytes/LayoutTransChanging.zip

DevBytes: PictureViewer

PictureViewer: How to use ViewPropertyAnimator to get a cross-fade effect as new bitmaps get installed in an ImageView. TransitionDrawable is a handy and easy facility for cross-fading between two drawables. But if you want to cross-fade between an arbitrary set of images, you might want something more general-purpose. Here's one approach. YouTube: https://www.youtube.com/watch?v=9XbKMUtVnJA Code: http://developer.android.com/shareables/devbytes/PictureViewer.zip

DevBytes: Request During Layout

Horrible things can result from calling requestLayout() during a layout pass. DON'T DO THIS . The demo that I wrote to show why this is bad seems very contrived, but I have since run across application code that did nearly the exact same thing, explicitly calling requestLayout() during onLayout(). Ugh. Typically, the cases where this problem occurs are a tad more subtle than that. YouTube: https://www.youtube.com/watch?v=HbAeTGoKG6k Code: http://developer.android.com/shareables/devbytes/RequestDuringLayout.zip

DevBytes: ListView Deletion

How animating ListView views can lead to artifacts if those views are recycled before you animate them. YouTube: https://www.youtube.com/watch?v=NewCSg2JKLk Code: http://developer.android.com/shareables/devbytes/ListViewDeletion.zip

DevBytes: ListView Animations

How animating ListView items can lead to problems as views are recycled, and how to perform these types of animations correctly with new API added in Jellybean. Code: http://developer.android.com/shareables/devbytes/ListViewAnimations.zip YouTube: https://www.youtube.com/watch?v=8MIfSxgsHIs

DevBytes: KeyFrame Animations

How to use AnimationDrawable to construct a keyframe animation where each frame is shown for a specified duration. YouTube: http://www.youtube.com/watch?v=V3ksidLf7vA Code: http://developer.android.com/shareables/devbytes/KeyframeAnimation.zip

DevBytes: Bounce Animations

Simple uses of ValueAnimator, ObjectAnimator, and interpolators to control how a shape is moved around on the screen. Code:  http://developer.android.com/shareables/devbytes/Bouncer.zip Video:  https://www.youtube.com/watch?v=vCTcmPIKgpM

DevBytes: BitmapAllocation

This example shows how to speed up bitmap loading and reduce garbage collection by reusing existing bitmaps. Note that the reused bitmap must be mutable and of the same size and configuration as the bitmap you load into it. Not sure if this is clear from the video, although it is documented in the API. Code: http://developer.android.com/shareables/devbytes/BitmapAllocation.zip Video: http://www.youtube.com/watch?v=rsQet4nBVi8

DevBytes: BitmapScaling

This example shows how the use of BitmapOptions affects the resulting size of a loaded bitmap. Sub-sampling can speed up load times and reduce the need for large bitmaps in memory if your target bitmap size is much smaller, although it's good to understand that you can't get specific Bitmap sizes, but rather power-of-two reductions in sizes. Code: http://developer.android.com/shareables/devbytes/BitmapScaling.zip Video: http://www.youtube.com/watch?v=12cB7gnL6po

DevBytes: Short, Focused Android Tutorials

The Android team has just rolled out the first four shows in a new series called DevBytes, which is intended to be very short, focused tutorials on specific developer topics. A quick explanation, maybe a demo, and a few lines of code to walk through and it's done. Taking a break from work? Want to learn something new? Or just wonder how a specific piece of technology works on the platform? Tune into one of the DevBytes episodes to get a quick deep dive into that exact topic (well, assuming we've done a show on that topic. Maybe we could interest you in one of the shows that we've actually filmed yet instead?) The first few of these feature ... me! (Surprise, surprise!) I'll be doing many of these tutorials over time, especially in the areas of animation, graphics, and UI development, starting with this first set: ViewAnimations : This show covers the basics of creating and running pre-3.0 Animations on View objects. PropertyAnimations : This show parallels the ViewAnima...

Curved Motion in Android

The animation support added in Android 3.0 and enhanced since then is useful, allowing a flexible system of property animation to animate literally anything you want. Like a store going out of business: if it ain't nailed down, it's up for grabs. But that doesn't mean we're done yet; there are many things that we'd like to do to keep improving the animation system and making Android animations easier to write and more powerful. One of those things is curved motion. Right now, if you animate something between a start and end point, it will move in a straight line between those values. For example, a translation animation, where the object moves from one (x, y) location to another, will move in a straight line beween those points. You can (and should) use non-linear timing for these animations, and the animation framework uses ease-in/ease-out timing by default. But the actual spacial movement is linear; there is no way for you to specify a curved path for an object...