UnderLineLinkTextView
简介:支持部分关键字带下划线可点击的 TextView
Support some of the key words can be clicked with the underline TextView
<declare-styleable name="AutoLinkStyleTextView">
<attr name="AutoLinkStyleTextView_text_value" format="string|reference"/>//key word with color and underline, and split with ','(en)
<attr name="AutoLinkStyleTextView_default_color" format="color|reference"/>//word and underline's color
<attr name="AutoLinkStyleTextView_has_under_line" format="boolean"/>//underline with true and false
</declare-styleable>
use, for example:
<xx.AutoLinkStyleTextView
android:id="@+id/tv_clause"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我已核对付款金额,仔细阅读并同意“购买须知”及约克论坛团购“用户条款”"
android:textSize="16sp"
app:AutoLinkStyleTextView_text_value="“购买须知”,“用户条款”"
/>
autoLinkStyleTextView.setOnClickCallBack(new AutoLinkStyleTextView.ClickCallBack() {
@Override
public void onClick(int position) {
if (position == 0) {
Toast.makeText(MainActivity.this, "购买须知", Toast.LENGTH_SHORT).show();
} else if (position == 1) {
Toast.makeText(MainActivity.this, "用户条款", Toast.LENGTH_SHORT).show();
}
}
});