android_重写button样式
事实上layer-list有点像framlayout,作用就是覆盖。
然后再画一个矩形将白色背景覆盖上面,设置android:left | right | top |bottom值。能够实现边框的大小。
然后在button里面设置background属性就好了,以下附上源代码。
他们当中的差别也仅仅是Radius的差别。
<div style="text-align: left;"><pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 连框颜色值 -->
<item>
<shape>
<solid android:color="#ff0000" /> //背景填充红色 <corners
android:bottomRightRadius="4dp" //设置圆角
android:topRightRadius="4dp" />
</shape>
</item>
<!-- 主体背景颜色值 -->
<item
android:bottom="1dp" //边框的宽度
android:right="1dp"
android:top="1dp">
<shape>
<solid android:color="#ffffff" /> <corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" /> <padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
</item> </layer-list>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_centerHorizontal="true"
android:background="@drawable/button_mid" <span style="font-family: Arial, Helvetica, sans-serif;">//设置button的形状</span> android:text="Button3" /> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_toRightOf="@+id/button3"
android:background="@drawable/button_right" //设置button的形状
android:text="Button2" /> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="110dp"
android:layout_toLeftOf="@+id/button3"
android:background="@drawable/button_left" <span style="font-family: Arial, Helvetica, sans-serif;">//设置button的形状</span>
android:text="Button1" /> </RelativeLayout>
android_重写button样式的更多相关文章
- WPF重写Button样式
首先指定OverridesDefaultStyle属性为True: 然后添加样式: 重写ControlTemplate: <Window.Resources> <Style x:Ke ...
- 重写 button 的创建方法
重写 button 的创建方法 //sxc时时改变 // self.videoM.progress = progress; // if ([self.videoM.downloadStr isEqua ...
- 【译文】CSS技术:如何正确的塑造button样式!
, but useful for */ display: inline-block; text-align: center; text-decoration: none; /* create a sm ...
- 36种漂亮的CSS3网页按钮Button样式
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- android中样式和自定义button样式
1)自定义button样式 一.采用图片方式 首先新建Android XML文件,类型选Drawable,根结点选selector,自定义一个文件名. 随后,开发环境自动在新建的文件里加了select ...
- wpf 导出Excel Wpf Button 样式 wpf简单进度条 List泛型集合对象排序 C#集合
wpf 导出Excel 1 private void Button_Click_1(object sender, RoutedEventArgs e) 2 { 3 4 ExportDataGrid ...
- CSS开发技巧(一):button样式设置
button样式需要注意的有几点: 1.建议有一个最小宽度,以免在文字很少时使得按钮过于窄,宽高不协调: 2.建议有一个padding,以免内部文本显得过于拥挤: 2.hover时需要有颜色变化,以告 ...
- swift 定制自己的Button样式
swift的UIButton类中有些公开方法可以重写,所以,如果想写出自己的UIButton,只要继承UIButton类,并重写相应的方法即可. 系统的UIButton可以添加图片,也可以添加标题,但 ...
- UWP 改变Button样式
-----some words------ 1.Control:控制 (我们理解成控件) 2.Template:模板 3.Ellipse 椭圆 4.Content 内容 5.Presenter 节目主 ...
随机推荐
- ASP.NET - 记录错误日志
不需要像log4net/Nlog/Common Logging配置,简单好用. 不用增加声明logger对象,可记录当前执行状况. 可以定义 维护功能模板的开发人员,以便用功能模块对于开发人员. 出处 ...
- Linux - 文件基本操作管理
文件基本操作管理 复制文件和目录 格式: Cp 源文件(文件夹) 新目标文件名(文件夹) 相同目录下,指定文件名. 不同目录下,不需要指定文件名. 参数: –r:递归复制整个目录树. –v:再复制 ...
- Vmware linux 安装 Vmware Tools 提示只读
在Vmware 虚拟机里安装完linux ,安装Vmware Tools,的时候会提示只读问题,是因为在安装 Vmware Tools 使用的是光盘挂在,光盘为只读文件,所以没有办法再光盘上直接的解压 ...
- SpringMVC之Controller传递JSON数据到页面
在Controller中,组装好JSON格式的数据,然后输入到页面,或者通过ajax请求在页面进行解析,都可以做到. 1.Controller /** * JSON DATA TO PAGE VEIW ...
- 基于visual Studio2013解决面试题之0209最大堆排序
题目
- [置顶] JSP分页,使用Hibernate+mysql
此代码为博主参考巴巴运动网源码所得,大部分一样,略有修改,在这里分享给大家,也方便自己以后写代码直接copy,看网上很多分页代码JSP里是用JAVA代码,博主原来也是这样,看到源码了解了JSTL,建议 ...
- Hibernate获取Connection
package com.trendcom.base.util; import java.sql.Connection; import java.sql.SQLException; import jav ...
- 利用PHP SOAP扩展实现简单Web Services
原文:利用PHP SOAP扩展实现简单Web Services WebServices能干什么? WebServices 可以将应用程序转换为网络应用程序. 通过使用 WebServices,您的应用 ...
- How to write simple HTTP proxy with Boost.Asio
How to write simple HTTP proxy with Boost.Asio How to write simple HTTP proxy with Boost.Asio Russia ...
- Java Swing界面编程(28)---复选框:JCheckBox
程序能够通过JRadioButton实现单选button的功能,那么要实现复选框的功能,则必须使用JCheckBox完毕. package com.beyole.util; import java.a ...