Home | History | Annotate | only in /developers/samples/android/ui/text
Up to higher level directory
NameDateSize
.google/21-Aug-2018
CONTRIBUTING.md21-Aug-20181.6K
LICENSE21-Aug-201831.5K
README.md21-Aug-20183.3K
screenshots/21-Aug-2018
TextStyling-Java/21-Aug-2018
TextStyling-Kotlin/21-Aug-2018

README.md

      1 Text Styling
      2 ============
      3 These samples shows how to style text on Android using spans, in [Java](https://github.com/googlesamples/android-text/tree/master/TextStyling-Java) and in [Kotlin](https://github.com/googlesamples/android-text/tree/master/TextStyling-Kotlin).
      4 
      5 
      6 Introduction
      7 ------------
      8 The difference between [TextStyling-Java](https://github.com/googlesamples/android-text/tree/master/TextStyling-Java) and [TextStyling-Kotlin](https://github.com/googlesamples/android-text/tree/master/TextStyling-Kotlin) is only in the language. They have the same set of features, same class names and similar ways of testing the functionality.
      9 ## Features
     10 Parse some hardcoded text and do the following:
     11 * Paragraphs starting with >  are transformed into quotes.
     12 * Text enclosed in ``` will be transformed into inline code block.
     13 * Lines starting with +  or *  will be transformed into bullet points.
     14 To update the text, modify the value of `R.string.display_text`.
     15 This project is not meant to fully cover the markdown capabilities and has several limitations; for example, quotes do not support nesting other elements.
     16 
     17 ## Implementation
     18 The text is parsed in the `Parser.parse` method and the spans are created in the `MarkdownBuilder.markdownToSpans` method.
     19 To see how to apply a span, check out `MarkdownBuilder.buildCodeBlockSpan`. To see how to apply multiple spans on the same string, see `MarkdownBuilder.buildQuoteSpan`. For examples of creating custom spans, see `BulletPointSpan`, `CodeBlockSpan` or `FontSpan`.
     20 
     21 ## Testing
     22 Text parsing is tested with JUnit tests in `ParserTest`. Span building is tested via Android JUnit tests, in `MarkdownBuilderTest`.
     23 
     24 
     25 Getting Started
     26 ---------------
     27 
     28 Clone this repository, enter the top level directory and run `./gradlew tasks`
     29 to get an overview of all the tasks available for this project.
     30 
     31 Some important tasks are:
     32 
     33 ```
     34 assembleDebug - Assembles all Debug builds.
     35 installDebug - Installs the Debug build.
     36 connectedAndroidTest - Installs and runs the tests for Debug build on connected
     37 devices.
     38 test - Run all unit tests.
     39 ```
     40 
     41 Screenshots
     42 -----------
     43 <img src="screenshots/main_activity.png" width="30%" />
     44 
     45 Support
     46 -------
     47 - Stack Overflow: http://stackoverflow.com/questions/tagged/android-text
     48 
     49 If you've found an error in this sample, please file an issue:
     50 https://github.com/googlesamples/android-text/issues
     51 
     52 Patches are encouraged, and may be submitted by forking this project and
     53 submitting a pull request through GitHub.
     54 
     55 License
     56 --------
     57 ```
     58 Copyright 2018 The Android Open Source Project
     59 
     60 Licensed to the Apache Software Foundation (ASF) under one or more contributor
     61 license agreements. See the NOTICE file distributed with this work for
     62 additional information regarding copyright ownership. The ASF licenses this
     63 file to you under the Apache License, Version 2.0 (the "License"); you may not
     64 use this file except in compliance with the License. You may obtain a copy of
     65 the License at
     66 
     67    http://www.apache.org/licenses/LICENSE-2.0
     68 
     69 Unless required by applicable law or agreed to in writing, software
     70 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     71 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     72 License for the specific language governing permissions and limitations under
     73 the License.
     74 ```
     75 
     76