项目作者: joshuadeguzman

项目描述 :
A fast and simplified spannable string builder.
高级语言: Kotlin
项目地址: git://github.com/joshuadeguzman/Spanly.git
创建时间: 2019-02-11T08:47:41Z
项目社区:https://github.com/joshuadeguzman/Spanly

开源协议:

下载


Spanly

A fast and simplified spannable string builder.

Kotlin
Build Status
GitHub (pre-)release

TODO’s

On-going development available at Projects Section.

Features

  • Fast
  • Simplified Spannable APIs
  • Lightweight

Demo

Beautifully designed typography posters made with Spanly!

design-one
design-two

Spans

Spanly Spans
bold()
italic()
underline()
strike()
sup()
sub()
background(color: Int)
color(color: Int)
size(size: Float)
font(typeface: Typeface)
clickable(listener: View.OnClickListener, isUnderlineText: Boolean = false)

Usage

  1. // MainActivity.kt
  2. // Design 1
  3. override fun onCreate(savedInstanceState: Bundle?) {
  4. super.onCreate(savedInstanceState)
  5. setContentView(R.layout.activity_main)
  6. // Render sample font
  7. val fontAvenirBold = Typeface.createFromAsset(assets, "fonts/avenir_bold.ttc")
  8. val fontBrillianteRegular = Typeface.createFromAsset(assets, "fonts/brilliante_regular.ttf")
  9. // Sample usage
  10. tvMessage.text =
  11. Spanly()
  12. .append(
  13. "TALK",
  14. font(fontAvenirBold),
  15. size(1.5f),
  16. italic(),
  17. clickable(View.OnClickListener {
  18. startActivity(Intent(this, SubActivity::class.java))
  19. finish()
  20. }),
  21. color(ContextCompat.getColor(this, R.color.colorOrange))
  22. )
  23. .space()
  24. .append("IS", font(fontAvenirBold), color(Color.WHITE), underline(), size(1.5f))
  25. .next()
  26. .append(
  27. "Cheap",
  28. font(fontBrillianteRegular),
  29. size(5f),
  30. clickable(View.OnClickListener {
  31. startActivity(Intent(this, SubActivity::class.java))
  32. finish()
  33. }),
  34. color(ContextCompat.getColor(this, R.color.colorBlueLight))
  35. )
  36. // Important for the click to work
  37. // More on https://developer.android.com/reference/android/text/method/LinkMovementMethod
  38. tvMessage.movementMethod = LinkMovementMethod.getInstance()
  39. }

Installation

  1. repositories {
  2. maven { url "https://jitpack.io" }
  3. }
  4. dependencies {
  5. // Replace version with release version, e.g. 1.0.0-alpha, -SNAPSHOT
  6. implementation 'io.jmdg:spanly:[VERSION]'
  7. }

License

Spanly is released under the MIT License. See LICENSE for details.

Contributing

  1. Fork it (https://github.com/joshuadeguzman/Spanly/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request