How to make a button that shows the backspace (⌫) character on Android?
Seems like the default Android font (Roboto / droid sans serif) doesn't include this character, so it can't display it (I still haven't figured out how the preview shows it). So you need to find a font that supports this character. The best candidate I've found is Arial Unicode MS, but these work too:
- Quivira (free)
- Symbola
- Segoe UI (windows phone's)
- DejaVu sans (free)
- Apple Symbols
My approach is to use an ImageButton
together with standard platform Drawables. You can actually see the standard Drawables available for various platforms by browsing your Android SDK directory: Sdk/platforms/android-XXX/data/res/
This gives you a button with the backspace symbol:
<ImageButton android:src="@drawable/sym_keyboard_return" ... />
Note: Google actually advise against referencing Android resources directly and advise making a local copy (see here). Therefore, try the above to see what the icon looks like (or have a browse inside the SDK folders mentioned above to see all the .png drawables directly), but for production it is best to copy the .png images for each desired resolution to your own project and reference those.
For what it's worth, there are various other very useful symbol images, such as a 'return' symbol (sym_keyboard_return.png, for example). Many of them such as sym_keyboard_return aren't referenced in android.R anyhow for some reason, so you certainly have to copy that particular one to your project.