TextView設定動態改變顏色

2021-09-01 11:21:26 字數 774 閱讀 6241

第1種:tv.settextcolor(android.graphics.color.red);//系統自帶的顏色類

第2種:tv.settextcolor(0xffff00ff);//0xffff00ff是int型別的資料,分組一下0x|ff|ff00ff,0x是代表顏色整數的標記,ff是表示透明度,ff00ff表示顏色,注意:這裡ffff00ff必須是8個的顏色表示,不接受ff00ff這種6個的顏色表示。

第3種:tv.settextcolor(this.getresources().getcolor(r.color.red));//通過獲得資源檔案進行設定。根據不同的情況r.color.red也可以是r.string.red或者r.drawable.red,當然前提是需要在相應的配置檔案裡做相應的配置,如:

#ff0000

#ff0000

#ff0000

第4種:動態給文字設定顏色選擇器

textview.settextcolor(getresources().getcolorstatelist(r.color.selector_title_color));注意:必須在src目錄新建乙個color資料夾,然後再建立乙個選擇器,**如下
<?xml version="1.0" encoding="utf-8"?>

Android EditText 改變邊框顏色

第一步 為了更好的比較,準備兩個一模一樣的edittext 當activity啟動時,焦點會在第乙個edittext上,如果你不希望這樣只需要寫乙個高度和寬頻為0的edittext即可避免,這裡就不這麼做了 如下 html view plain copy edittext android layou...

改變textview部分字型顏色

skip to end of metadata go to start of metadata 一 使用spanner textview為需要改變字型顏色的控制項 spannablestringbuilder builder new spannablestringbuilder textview.g...

MapXtremE 中改變feature顏色

1.c code mapinfo.data.table table mapinfo.engine.session.current.catalog.opentable c programfiles mapinfo mapxtreme2004 maps north america usa.tab thi...