每一件事情都要從基礎(chǔ)做起,其實(shí)理論知識(shí)真的很重要。 這里進(jìn)行的事基礎(chǔ)知識(shí)的總結(jié): 在應(yīng)用里面經(jīng)常遇到統(tǒng)一樣式格式的問(wèn)題,那么與沒(méi)有類(lèi)似CSS的樣式方法統(tǒng)一指定大小,顏色,選中效果等等 下面我們就進(jìn)行統(tǒng)一設(shè)置樣式:
在res/values下面創(chuàng)建一個(gè)style.xml
初始化創(chuàng)建內(nèi)容是:
<?xml version="1.0" encoding="utf-8"?>
<resources> </resources> 下面是我們添加的兩個(gè)簡(jiǎn)單樣式設(shè)計(jì),當(dāng)然你也可以自己進(jìn)行其他屬性的設(shè)計(jì): <?xml version="1.0" encoding="utf-8"?>
<resources> <style name="customStyle1"> <style name="customStyle2"> </resources>
在使用這些樣式的方法: 比如:
<TextView
android:text="格式2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/customStyle2"
/>
|
|
來(lái)自: Sunny_Gql > 《android 文章整理》