[英]Android Linkify how to set custom link color?
我想將我的 android 鏈接文本顏色設置為自定義顏色,但是mText.setLinkTextColor("#2f6699");
不起作用,我一直在尋找一種可以編譯十六進制值的內置方法,但我還沒有找到,任何幫助都會大有幫助,謝謝
您應該將其轉換為顏色。 嘗試:
mText.setLinkTextColor(Color.parseColor("#2f6699"));
您也可以在 xml 中使用android:textColorLink="#2f6699"
。
嘗試這樣的事情:
noteView.setLinkTextColor(Color.green);
如果要設置十六進制顏色:
noteView.setLinkTextColor(Color.argb(int alpha, int red, int green, int blue));
用所需的值替換 alpha/red/green/blue。 可以在此處找到有關 Color 類的文檔
由於 resources.getColor() 函數已棄用,我們可以嘗試這種替代方法。
textView.setLinkTextColor(ContextCompat.getColor(this,R.color.colorBlue))
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.