亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android 設(shè)置顏色的方法總結(jié)

 更新時(shí)間:2017年09月25日 11:02:11   作者:zhangqijie001  
這篇文章主要介紹了Android 設(shè)置顏色的方法總結(jié)的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家掌握設(shè)置顏色的方法,需要的朋友可以參考下

Android 設(shè)置顏色的方法總結(jié)

Android中有幾種設(shè)置界面背景及文字顏色的方法,下面由淺入深分別介紹Android中設(shè)置顏色的幾種方法:

1.直接在布局文件中設(shè)置:

android:backgound="#FFFFFFFF", android:textcolor="#00000000"

2.把顏色提取出來(lái)形成資源,放在資源文件下面(values/drawable/color.xml):

<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="white">#FFFFFFFF</drawable>
<drawable name="black">#FF000000</drawable>
</resources>

然后在布局文件中使用:

android:backgound="@drawable/white", android:textcolor="@drawable/black"

或者在java文件中通過(guò)

setBackgroundColor(int color), setBackgroundResource(int resid), setTextColor(int color)

以上兩種方法主要依據(jù)布局文件,自由度不大。

3.在java文件中動(dòng)態(tài)設(shè)定,主要通過(guò)兩種形式:

(1)利用Drawable的子類(lèi)ColorDrawable

 ColorDrawable(int color), setBackgroundDrawble(Drawable drawable)

(2)直接利用Drawable

  獲取資源getResources(), 通過(guò)2種的drawable的id獲取Drawable:Resources.getDrawable(int id)

如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論