新聞中心
一.自定義控件的選中效果
你所需要的網(wǎng)站建設(shè)服務(wù),我們均能行業(yè)靠前的水平為你提供.標(biāo)準(zhǔn)是產(chǎn)品質(zhì)量的保證,主要從事成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司、企業(yè)網(wǎng)站建設(shè)、手機(jī)網(wǎng)站制作設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)、品牌網(wǎng)站制作、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。創(chuàng)新互聯(lián)建站擁有實(shí)力堅(jiān)強(qiáng)的技術(shù)研發(fā)團(tuán)隊(duì)及素養(yǎng)的視覺設(shè)計(jì)專才。
在drawable文件夾下新建selector類型的xml文件(右鍵drawable,選擇新建android xml file),文件名任意,內(nèi)容如:
xmlns:android="http://schemas.android.com/apk/res/android">
?xml>
/*state_focused表示是否是非觸摸狀態(tài),true表示是非觸摸狀態(tài)。其中android:drawable可以引用drawable文件夾下其它資源文件,比如shape資源,用來實(shí)現(xiàn)控件常規(guī)、按下、選中等樣式*。
使用方法:在布局文件中,控件的背景屬性中引用這些資源,以下類同*/
二.自定義控件的外觀
新建shape類型的xml文件,如:
?xml>
android:width="1px"
android:color="@color/color_black" />
android:bottom="3dp"
android:left="3dp"
android:right="3dp"
android:top="3dp" />
android:color="@color/color_white"
/>
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:radius="1dp"
android:topLeftRadius="@dimen/indicator_corner_radius"
android:topRightRadius="@dimen/indicator_corner_radius" />
/*
stroke表示描邊
padding內(nèi)邊距
solid表示實(shí)體,即控件的整體區(qū)域
corners表示圓角
*/
三.多樣式疊加
新建layer-list類型的xml文件,如:
?xml>
android:width="1dp"
android:color="@color/stroke" />
android:scaleGravity="center"
android:scaleHeight="5dp"
android:scaleWidth="5dp" />
綜合示例:
android:centerY="1" android:angle="270" />
?xml>
android:startColor="#ffaaa9a7"
android:centerColor="#ffaaa9a7"
android:centerY="1"
android:endColor="#ffaaa9a7"
android:angle="270"
/>
android:centerY="1" android:angle="270" />
新聞標(biāo)題:Android利用drawable文件夾自定義控件背景、樣式
標(biāo)題網(wǎng)址:http://fisionsoft.com.cn/article/iiejoc.html