安卓資源檔擷取與使用

來源:互聯網
上載者:User

標籤:

    /**     * 代碼中設定布局控制項顏色的方法     * 參考:     *  http://yahaitt.iteye.com/blog/454615     *  http://blog.csdn.net/fantianheyey/article/details/9208771     *  http://txlong-onz.iteye.com/blog/1249609     *  http://my.oschina.net/u/2320057/blog/549507     *  http://blog.csdn.net/shulianghan/article/details/19913755     */    @Override    public void initDatas() {        //系統內建的顏色類        tvColorText.setTextColor(Color.GREEN);        //0xffff00ff是int類型的資料,分組一下0x|ff|ff00ff,0x是代表顏色整數的標記,ff是表示透明度,        //ff00ff表示顏色,注意:這裡0xff-ff-00-ff必須是8個的顏色表示,不接受ff00ff這種6個的顏色表示。        tvColorText.setTextColor(0xFFCCCCCC);        tvColorText.setTextColor(Color.rgb(55, 55, 55));        tvColorText.setTextColor(Color.parseColor("#87CEFA"));        //通過獲得資源檔進行設定        //可引用資源檔中的顏色屬性        //<color name="red">#FF0000</color>        //<drawable name="red">#FF0000</drawable>        //<string name="red">#FF0000</string>        tvColorText.setTextColor(getResources().getColor(R.color.colorAccent));    }

 

安卓資源檔擷取與使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.