提供自定义TextViews风格更简单的方法:BabushkaText

jopen 11年前

BabushkaText提供一种更简单的方法来自定义TextViews风格。BabushkaText是一个自定义TextView,让你能够通过Spannables来定制文本部分的风格。但无需直接处理Spannable的麻烦。

  • Create complex style structures for your text without having to add multiple TextViews to your view hierarchy.
  • Eliminate setSpan(Object what, int start, int end, int flags) calls by using more convenient methods such as .style(Typeface.BOLD), .superscript() and others.

example.png

        BabushkaText babushka = (BabushkaText)findViewById(R.id.babushka_text);            // Add the first piece "Central Park"          babushka.addPiece(new BabushkaText.Piece.Builder("Central Park, NY\n")                  .textColor(Color.parseColor("#414141"))                  .build());            // Add the second piece "1.2 mi"          babushka.addPiece(new BabushkaText.Piece.Builder("1.2 mi ")                  .textColor(Color.parseColor("#0081E2"))                  .textSizeRelative(0.9f)                  .build());            // Add the third piece "from here"          babushka.addPiece(new BabushkaText.Piece.Builder("from here")                  .textColor(Color.parseColor("#969696"))                  .textSizeRelative(0.9f)                  .build());            // Display the final, styled text          babushka.display();

项目主页:http://www.open-open.com/lib/view/home/1417443546697