Text selection
Part of the material design guide specifications discuss text selection in your applications. Users select text within your app, and you now have an API to incorporate a floating toolbar design pattern that's similar to a contextual action bar. For more information about the design specifications, head to http://www.google.com/design/spec/patterns/selection.html#selection-item-selection.
The implementation steps are as follows:
Change your
ActionMode
calls tostartActionMode(Callback,ActionMode.TYPE_FLOATING)
.Extend
ActionMode.Callback2
.Override the
onGetContentRect()
method and provide coordinates for the contentRect
object in the view.Call the
invalidateContentRect()
method when you need to invalidate theRect
object and it's position is no longer valid.
Support library notice
Floating toolbars are not backward-compatible. Appcompat
takes control over ActionMode
objects by default. This will prevent floating toolbars from being displayed.
The implementation steps are as follows...