GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - junerver/SpannableStringDslExtension

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
art
art
 
 
gradle/wrapper
gradle/wrapper
 
 
library
library
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

SpannableStringDslExtension

思路见文章在 Kotlin 中巧妙的使用 DSL 封装 SpannableStringBuilder

相比文章做了更多的扩展,利用 kotlin 语法糖做了一些有趣的事情,欢迎star & PR。

使用: implementation 'xyz.junerver.ssktx:ss-ktx:0.0.4'

通过一个扩展函数,使用 DSL 风格的代码,轻松的构建 SpannableString :

textView.buildSpannableString {
   "你可以这样,".asSpannableString {
       setBackgroundColor("#ff0099")
   }
   "还可以这样用"{
       setBackgroundColor("#ffff99")
   }
   addText("\n我已详细阅读并同意") {
       setBackgroundColor("#FF9900")
       setStyle(Typeface.BOLD_ITALIC)
       userUnderLine()
       useStrikethrough()
       setDrawableRight(R.drawable.icon_dingding, DynamicDrawableSpan.ALIGN_CENTER)
   }
   addText("\n打电话") {
       asURL("tel:10086")
   }
   addText("《隐私政策》") {
       setForegroundColor("#0099FF")
       setDrawableLeft(R.drawable.icon_wechat)
       onClick {

       }
   }
}

About

No description, website, or topics provided.

Resources

Readme
Apache-2.0 license
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.