Monthly archives: August, 2016

Defining Shadows and Clipping Views in Android

Material design introduces elevation for UI elements. Elevation helps users understand the relative importance of each element and focus their attention to the task at hand. The elevation of a view, represented by the Z property, determines the visual appearance of its shadow: views with higher Z values cast larger, softer shadows. Views with higher …

Creating Lists and Cards in Android

To create complex lists and cards with material design styles in your apps, you can use the RecyclerView and CardView widgets. Create Lists The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited …

Using the Material Theme in Android

The new material theme provides: System widgets that let you set their color palette Touch feedback animations for the system widgets Activity transition animations You can customize the look of the material theme according to your brand identity with a color palette you control. You can tint the action bar and the status bar using …

Dragging and Scaling in Android

This lesson describes how to use touch gestures to drag and scale on-screen objects, using onTouchEvent() to intercept touch events. Drag an Object If you are targeting Android 3.0 or higher, you can use the built-in drag-and-drop event listeners withView.OnDragListener, as described in Drag and Drop. A common operation for a touch gesture is to …

Handling Multi-Touch Gestures in Android

A multi-touch gesture is when multiple pointers (fingers) touch the screen at the same time. This lesson describes how to detect gestures that involve multiple pointers. Track Multiple Pointers When multiple pointers touch the screen at the same time, the system generates the following touch events: ACTION_DOWN—For the first pointer that touches the screen. This …

Animating a Scroll Gesture in Android

In Android, scrolling is typically achieved by using the ScrollView class. Any standard layout that might extend beyond the bounds of its container should be nested in aScrollView to provide a scrollable view that’s managed by the framework. Implementing a custom scroller should only be necessary for special scenarios. This lesson describes such a scenario: …

Tracking Movement in Android

This lesson describes how to track movement in touch events. A new onTouchEvent() is triggered with an ACTION_MOVE event whenever the current touch contact position, pressure, or size changes. As described in Detecting Common Gestures, all of these events are recorded in the MotionEvent parameter of onTouchEvent(). Because finger-based touch isn’t always the most precise …

Detecting Common Gestures in Anroid

A “touch gesture” occurs when a user places one or more fingers on the touch screen, and your application interprets that pattern of touches as a particular gesture. There are correspondingly two phases to gesture detection: Gathering data about touch events. Interpreting the data to see if it meets the criteria for any of the …

Maintaining Compatibility in Android

Some material design features like the material theme and custom activity transitions are only available on Android 5.0 (API level 21) and above. However, you can design your apps to make use of these features when running on devices that support material design and still be compatible with devices running previous releases of Android. Define …

Defining Custom Animations in Anroid

Animations in material design give users feedback on their actions and provide visual continuity as users interact with your app. The material theme provides some default animations for buttons and activity transitions, and Android 5.0 (API level 21) and above lets you customize these animations and create new ones: Touch feedback Circular Reveal Activity transitions …