為Android TextView增加高度可定制多彩的鏈接:LinkTextView
LinkTextView是一個為Android TextView增加高度可定制多彩鏈接的庫。
特性
- 易于增加鏈接和附加數據
- 設置鏈接的正常顏色和點過的顏色。
- 設置背景正常顏色,和點過的顏色。
示例
See the LinkTextViewSample for a common use of this library.
如何使用:
Download the LinkTextView.java file and copy it into your project.
Add LinkTextView to your layout.
<com.zekunyan.linktextview.LinkTextView
android:id="@+id/linkTextView"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#DDDDDD"
android:gravity="center"
android:textColor="#000000"
android:textSize="24sp" /> Get the instance of LinkTextView.
linkTextView = (LinkTextView) findViewById(R.id.linkTextView); Set text.
linkTextView.setClickableText("Example link."); Add link with default color.
int linkID = linkTextView.addClick(
linkBegin, //Link begin
linkEnd, //Link end
new LinkTextView.OnClickInLinkText() {
@Override
public void onLinkTextClick(String clickText, int linkID, Object attachment) {
Log.i(LOG_TAG, "You click manual link. It's attachment is: " + attachment);
}
},
"This is attachment." //Link attachment
); Or add link with custom color.
int linkID = linkTextView.addClick(
linkBegin, //Link begin
linkEnd, //Link end
new LinkTextView.OnClickInLinkText() {
@Override
public void onLinkTextClick(String clickText, int linkID, Object attachment) {
Log.i(LOG_TAG, "You click example link. It's attachment is: " + attachment);
}
},
"This is example link attachment", //Link attachment
true, //Show link underline
Color.BLACK, //Text normal color
Color.YELLOW, //Text pressed color
Color.WHITE, //Background normal color
Color.GREEN //Background pressed color
); You can change specific Link's color by its ID.
linkTextView.setTextPressedColor(linkID, Color.RED); You can remove specific link by its ID.
linkTextView.removeLink(linkID); 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!