1. 程式人生 > >Android 程式碼中獲取顏色 Color

Android 程式碼中獲取顏色 Color

        tv_color.setTextColor(0x123456)
        // 這個6.0 的已經過時了
        resources.getColor(R.color.abc_btn_colored_text_material);
        // 6.0 以上的
       this.getColor(R.color.abc_background_cache_hint_selector_material_light)

        //  可以用這個 context 物件
        ContextCompat.getColor(this,R.color
.abc_btn_colored_text_material) Color.red(0x12345); ` Color.rgb(11,11,11); Color.argb(11,11,11,11);