android客户端学习-button按钮边框及圆角
来源:互联网 发布:淘宝卖切糕 编辑:程序博客网 时间:2024/06/11 16:59
在drowable文件夹下创建button_border.xml
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- android:state_pressed 是否按下,如一个按钮触摸或者点击-->
<item android:state_pressed="true">
<shape>
<gradient android:startColor="@color/white" android:endColor="@color/white"
android:angle="90"/>
<stroke android:width="1dip" android:color="@color/black"/>
<corners android:radius="5dp"/>
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp"/>
</shape>
</item>
<!-- android:state_focused 是否取得焦点,比如用户选择了一个文本框 -->
<item android:state_focused="true">
<shape>
<gradient android:startColor="@color/white" android:endColor="@color/white"
android:angle="90"/>
<stroke android:width="1dip" android:color="@color/black"/>
<corners android:radius="5dp"/>
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp"/>
</shape>
</item>
<!-- 默认状态 -->
<item>
<shape>
<gradient android:startColor="@color/white" android:endColor="@color/white"
android:angle="90"/> <!--背景颜色-->
<stroke android:width="1dip" android:color="@color/black"/><!--边框宽度及颜色-->
<corners android:radius="5dp"/><!--圆角-->
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp"/>
</shape>
</item>
</selector>
在页面xml文件中调用如下:
<Button
android:id="@+id/order_add_btn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="40dp"
android:layout_marginStart="40dp"
android:layout_marginRight="40dp"
android:layout_marginEnd="40dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textColor="@color/white"
android:background="@drawable/button_border"
android:text="@string/btn_add"/>
- android客户端学习-button按钮边框及圆角
- android 客户端学习-给button按钮设置圆角
- Android 圆角按钮BUTTON
- 【Android】圆角边框Button的实现
- Android:为Button添加圆角黑色边框及透明底色
- android 给 button 添加边框及底色
- android 给 button 添加边框及底色
- android 给 button 添加边框及底色
- Android学习 12-> 按钮Button
- Androidの自定义圆角按钮button
- android实现的圆角按钮Button
- 设置button按钮边框颜色
- Android开发Button控件的圆角,边框
- 设置按钮圆角边框颜色及粗细
- android客户端学习-开关按钮
- android 学习 ---控件按钮,Button 与ImageButton,
- Android自定义Iphone风格的圆角边框开关按钮
- Android自定义Iphone风格的圆角边框开关按钮
- 解读ASP.NET 5 & MVC6系列(11):Routing路由
- 第六周 项目2-建立链栈算法库
- Python随机数
- 一个winform带你玩转rabbitMQ
- SQLiite3: 数据库文件使用UTF-16编码
- android客户端学习-button按钮边框及圆角
- Android内存泄露案例分析
- 第7周—项目1 建立顺序环形队列算法库
- 【笔试面试】75道逻辑推理题及答案
- FullCalendar应用——新建日程事件
- 解读ASP.NET 5 & MVC6系列(12):基于Lamda表达式的强类型Routing实现
- Python Flask script 使用
- 黑马程序员——Java基础--------IO流(二)
- Impala004-Impala管理