Android笔记:自定义Button
来源:互联网 发布:最准的掐指算法姻缘 编辑:程序博客网 时间:2024/05/21 08:59
在drawable下新建一个xml文件,直接把代码复制进去,完成之后直接在布局的button里设置background即可。
代码展示:
布局文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:id="@+id/id_welcome1" android:layout_height="match_parent" android:background="@mipmap/welcome3" > <!--#F6FBFF--> <Button android:id="@+id/btn_start" android:layout_width="200dp" android:layout_height="40dp" android:background="@drawable/shape2" android:text="立即体验" android:layout_marginBottom="51dp" android:textColor="#9BE226" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /></RelativeLayout>shape2.xml文件
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"><shape android:shape="rectangle"> <corners android:radius="4dp" /> <stroke android:width="1dp" android:color="#cccccc"></stroke> <gradient android:angle="270" android:endColor="#ffebd8" android:startColor="#f5fcff" /> </shape></item> <item><shape android:shape="rectangle"> <corners android:radius="4dp" /> <stroke android:width="1dp" android:color="#dedede"></stroke> <gradient android:angle="270" android:endColor="#ece6e1" android:startColor="#fcfcfc" /> </shape></item></selector> <!-- Android:startcolor和android:endcolor分别为起始和结束颜色 --> <!-- android:angle是渐变角度。angle=“0”,angle=“360”时,是从左到右 ;angle=“90”是从上到下;android:angle=“180”是从右到左 --> <!-- stroke:描边 --> <!-- android:color 描边的颜色 --> <!-- corners:圆角 android:radius为角的弧度,值越大角越圆。 -->
0 0
- Android笔记:自定义Button
- android学习笔记 自定义圆角Button
- Android应用开发笔记(10):制作自定义背景Button按钮、自定义形状Button的全攻略
- Android应用开发笔记(10):制作自定义背景Button按钮、自定义形状Button的全攻略
- Android应用开发笔记(10):制作自定义背景Button按钮、自定义形状Button的全攻略
- Android自定义Button组件
- android自定义button样式
- android之自定义button
- android 自定义button shape
- android 自定义BUtton
- Android自定义Button按钮
- android自定义button样式
- android自定义button样式
- android 自定义button样式
- Android:自定义Button
- android 自定义button
- android 自定义 button样式
- Android 自定义Action Button
- 关于springmvc一致停留“信息: Initializing Spring FrameworkServlet 'SpringMVC'”的问题
- angularJS2中的界面跳转
- linux 日常命令 tar
- wsdl文件转换为java代码
- SD卡初始化步骤总结
- Android笔记:自定义Button
- 30分钟带你熟练性能优化的那点儿事儿(案例说明)
- Android Activity自己重启的问题
- 十年的程序员:最危害程序员职业生涯的三大观念
- COM技术内幕--关于HRESULT、GUID、注册表及其他细节
- (2.2.2.9)Future接口和FutureTask类【FutureTask实现了Runnable和Future接口】
- 圆的最小二乘法拟合
- INTERSECT 两个单独的sql取交集
- java并发编程之AbstractQueuedSynchronizer