用shape仿視頻中藍(lán)色按鈕
在視頻中,老師的leftButton和rightButton是一個(gè)藍(lán)色的按鈕,很多同學(xué)引用之后出現(xiàn)錯(cuò)誤,那是因?yàn)闆](méi)有可引用的資源。現(xiàn)在就仿制一個(gè)藍(lán)色的按鈕。
首先在drawable資源文件夾下創(chuàng)建一個(gè)xml文件,名稱(chēng)任意。這里我起名為shape。
<?xml?version="1.0"?encoding="utf-8"??> ????<!--shape如果不聲明形狀默認(rèn)是正方形--> <shape?xmlns:android="http://schemas.android.com/apk/res/android"> ????<!--設(shè)置圓角--> ????<corners?android:radius="5dp"></corners> ????<!--設(shè)置填充色--> ????<solid?android:color="#0066ff"></solid> ????<!--設(shè)置邊框的顏色和寬度--> ????<stroke?android:color="#0066ff" ????????android:width="1dp"></stroke> </shape>
然后在布局文件中引用即可。
<ui.app.sonny.Topbar ????????android:id="@+id/topbar" ????????android:layout_width="match_parent" ????????android:layout_height="40dp" ????????custom:leftText="Back" ????????custom:leftTextColor="#FFFFFF" ????????custom:leftTextBackground="@drawable/shape" ????????custom:rightText="More" ????????custom:rightTextColor="#ffffff" ????????custom:rightTextBackground="@drawable/shape" ????????custom:topbarTitle="This?is?title" ????????custom:titleTextColor="#ffffff"></ui.app.sonny.Topbar>
效果如下:
更多內(nèi)容,請(qǐng)自行搜索!
2015-04-25
感謝你的分享~~
2016-07-02
如何設(shè)置點(diǎn)擊按鈕變色啊,這個(gè)無(wú)法呈現(xiàn)出點(diǎn)擊的視覺(jué)效果
2015-06-13
我想問(wèn)一下?可以實(shí)現(xiàn)去掉中間豎線的陰影嗎?
2015-06-12
贊一個(gè)
2015-05-25
謝謝你!