用shape仿視頻中藍色按鈕
在視頻中,老師的leftButton和rightButton是一個藍色的按鈕,很多同學引用之后出現錯誤,那是因為沒有可引用的資源?,F在就仿制一個藍色的按鈕。
首先在drawable資源文件夾下創建一個xml文件,名稱任意。這里我起名為shape。
<?xml?version="1.0"?encoding="utf-8"??> ????<!--shape如果不聲明形狀默認是正方形--> <shape?xmlns:android="http://schemas.android.com/apk/res/android"> ????<!--設置圓角--> ????<corners?android:radius="5dp"></corners> ????<!--設置填充色--> ????<solid?android:color="#0066ff"></solid> ????<!--設置邊框的顏色和寬度--> ????<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>
效果如下:
更多內容,請自行搜索!
2015-04-25
感謝你的分享~~
2016-07-02
如何設置點擊按鈕變色啊,這個無法呈現出點擊的視覺效果
2015-06-13
我想問一下?可以實現去掉中間豎線的陰影嗎?
2015-06-12
贊一個
2015-05-25
謝謝你!