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 节目主 ...
随机推荐
- JQuery 插件之Ajax Autocomplete(ajax自动完成)
平时用百度,谷歌搜索的时候 会有一个下 拉列表进行提示 这是一个非常好的功能 本文要介绍的这个JQuery 插件 名叫Ajax Autocomplete 顾名思义 ajax 也就是用ajax的方式获取 ...
- Effective C++ 第二版 8) 写operator new 和operator delete 9) 避免隐藏标准形式的new
条款8 写operator new 和operator delete 时要遵循常规 重写operator new时, 函数提供的行为要和系统缺省的operator new一致: 1)正确的返回值; 2 ...
- 百度贴吧客户端(Android)网络通信行为分析
百度贴吧安卓客户端网络通信行为分析 本文由CSDN-蚍蜉撼青松[主页:http://blog.csdn.net/howeverpf]原创,转载请注明出处! 一.实验环境与结果概述 1.1 实验环境 ...
- NTP工作机制及时间同步的方法
Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它能够使计算机对其server或时钟源做同步化,它能够提供高精准度的时间校正,且可用加密确认的方式来防止恶毒的协 ...
- PySide——Python图形化界面
PySide——Python图形化界面 PySide——Python图形化界面入门教程(四) PySide——Python图形化界面入门教程(四) ——创建自己的信号槽 ——Creating Your ...
- KVM 实现机制
1.1. KVM简介 KVM是一个基于Linux内核的虚拟机,它属于完全虚拟化范畴,从Linux-2.6.20开始被包含在Linux内核中.KVM基于x86硬件虚拟化技术,它的运行要求Intel ...
- Oracle 12C 简介
2013年6月26日,Oracle Database 12c版本正式发布,首先发布的版本号是12.1.0.1.0,率先提供下载的平台有Linux和Solaris: Oracle官方下载地址: http ...
- Delphi的指针 good
Pointers are like jumps, leading wildly from one part of the data structure to another. Their introd ...
- How to append files to a .tar archive using Apache Commons Compress?(转)
I created a copy of the tar archive and copied to entire content to it. Then I delete the old tar ar ...
- [Android学习笔记]EditText的使用
EditText就是我们最常用的文本输入框 常用属性见官方文档 主要是以下几个问题: 1.取消默认获取焦点 Activity启动时候会把焦点默认停留在第一个EditText控件上 一般的解决方法是在此 ...