shape

先看下,系统自带的EditText和Button的外形

下面看加了shape后的效果

简单点讲,shape可以为组件加上背景边框,圆角之类的可以配合selector使用

shapeXXX.xml定义在drawable目录下

EditText使用的

<?xml version="1.0" encoding="utf-8"?>
<!--
rectangle 矩形
oval 椭圆
line 一条线
ring 环形
-->
<shape
android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android"> <!--4个角的圆角-->
<corners android:radius="5dp"/> <!--内边距-->
<padding android:bottom="6dp"
android:left="5dp"
android:right="5dp"
android:top="6dp"/> <!--填充颜色
按需求要不要加
-->
<solid android:color="#FFFAE3"/> <!--边框颜色
需要 就加边框,
--> <stroke android:color="#87CEFA"
android:width="1dp"/> </shape>

Button使用的定义的都 一样

<?xml version="1.0" encoding="utf-8"?>
<!--
rectangle 矩形
oval 椭圆
line 一条线
ring 环形
-->
<shape
android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android"> <!--4个角的圆角-->
<corners android:radius="8dp"/> <!--内边距-->
<padding android:bottom="5dp"
android:left="3dp"
android:right="3dp"
android:top="5dp"/> <!--填充颜色-->
<solid android:color="#09A3DC"/> <!--边框颜色--> <stroke android:color="#88000000"
android:width="1dp"/> </shape>

布局中组使用在background属性中使用

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <EditText
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shap_et"
android:hint="请输入用户名" /> <Button
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@drawable/shap_btn"
android:text="确定"/>
</LinearLayout>

最新文章

  1. Team Foundation Server源代码管理多人开发的使用心得
  2. Jquery Mobile开发以及Js对象动态绑定
  3. Spring实现IOC
  4. js 不同进制之间相互转换
  5. 【转载】VMware虚拟机修改硬盘容量大小
  6. IOS 判断日期是今天,昨天还是明天
  7. nodejs 基本类型和语法
  8. 一步一步学习SignalR进行实时通信_1_简单介绍
  9. lightoj 1013 dp
  10. 帮助中心 7D-我的私家设计师 设计师品牌服饰集成网 7D服装定制!
  11. WinForm----DataGridview---连接数据库,以及双击一条数据,显示信息到Label控件,也可以是TextBox控件。
  12. C++ 对象成员函数(非静态方法)
  13. Python3 的函数
  14. 每天学点SpringCloud(二):服务注册与发现Eureka
  15. C++ 成员函数赋值给C 的函数指针的采坑录
  16. 转!!!解释Eclipse下Tomcat项目部署路径问题(.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps)
  17. 修改微软RDP远程桌面端口
  18. django的基本用法
  19. angularJS 状态样式绑定
  20. webpack-dev-server坑

热门文章

  1. Swift 2.2发布
  2. [AngularJS] AngularJS系列(2) 中级篇之路由
  3. SqlCommandBuilder实现大数据更新
  4. .net断点续传的原理
  5. Mysql高并发优化
  6. 【Java每日一题】20161025
  7. 泛函编程(32)-泛函IO:IO Monad
  8. PHP与MySQL的交互(mysqli)
  9. Verilog学习笔记简单功能实现(六)...............计数分频电路
  10. ahjesus 前端缓存原理 转载