Warning This sample has been migraated to the new platform-samples repository and will no longer be maintained.
Please use the following sample instead.
Thank you for your understanding.
This sample demonstrates several text-related features in Android.
buildSpannedString
in the core-ktx library is useful for quickly
building a rich text.
LinkifyCompat is useful for creating links in TextViews. The API supports email addresses, phone numbers, and web URLs out of the box, and you can also use regular expressions to create a custom link pattern.
Automatic hyphenation is available for a number of languages including English.
Android 6.0 Marshmallow (API level 23) introduced the
android:hyphenationFrequency
attribute to apply automatic hyphenation to a TextView
.
Android 13 (API level 33) introduced 2 new options, fullFast
and normalFast
. These are the same
as full
and normal
, but use faster algorithm for better performance.
This feature is relevant to languages written without spaces between words, such as Japanese and Chinese. This particular demo works only when the device locale is set to Japanese.
Android 13 (API level 33) introduced the android:lineBreakWordStyle
attribute to TextView
. Set
this attribute to "phrase"
, and
phrases (bunsetsu)
in the text will not be separated by line breaks.
This feature is relevant to Japanese language. You need the latest Gboard with Japanese language pack to use this demo.
Android 13 (API level 33) introduced Conversion Suggestion API that allows apps to access pieces of text before they are committed during a text conversion session. Apps can then use these suggestions to build incremental search queries, etc.
See ConversionEditText.kt and ConversionInputConnection.kt for the detail on how to use the API.
This sample uses the Gradle build system. To build this project, use the "gradlew build" command or open the sample folder in Android Studio.
- Stack Overflow: http://stackoverflow.com/questions/tagged/android
If you've found an error in this sample, please file an issue: https://github.com/android/user-interface
Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.