android自定义exittext和button
来源:互联网 发布:访客网络影响网速吗 编辑:程序博客网 时间:2024/06/13 20:13
写项目往往要自定义exittext和button
1、自定义button有两种效果:圆角、默认颜色、点击时颜色
左图:带渐变效果,一般按钮是这种的。上面两种都是定义两个背景
默认色,没有点击的背景:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="@android:color/white"/> <corners android:radius="8px" /></shape>点击后的背景:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <corners android:radius="8px" /> <gradient android:angle="90" android:centerX="0.5" android:centerY="0.5" android:endColor="#CCCCCC" android:startColor="#888888" android:type="linear" /> </shape>
右图:和左图基本一样,就是点击不是渐变色:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="@android:color/white"/> <corners android:radius="8px" /></shape>点击后:
<span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#CCCCCC"/> <corners android:radius="8px" /></shape></span>
上面两种效果的背景选择器:
<span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/log_btn_default" android:state_pressed="false"/> <item android:drawable="@drawable/log_btn_pressed" android:state_pressed="true"/></selector></span>
2、自定义edittext
edittext默认的是一条线,一般需要边框的,如圆角、边框颜色、填充空白
有个简单的背景图利用系统自带的背景:@android:drawable/edit_background_normal或者@android:drawable/edit_background
效果图:
要嘛自定义背景:
<span style="font-size:14px;"><img src="http://img.blog.csdn.net/20150902023946099?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />代码:</span><pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#2191FF"/> //背景色 <corners android:radius="8px" />//圆角 <stroke //边框 android:width="2px" android:color="#1B79FF" /> <padding android:left="8dp" android:top="8dp" android:right="8dp" android:bottom="8dp"/> /填充/空白</shape>
0 0
- android自定义exittext和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
- Android自定义Button
- android自定义button样式
- Android-自定义反色圆角Button
- android自定义Button
- MySQL for mac 安装
- C#Memory Management for Unity Developers (part 2 of 3)
- C# Memory Management for Unity Developers (part 3 of 3)
- 25 条提高 iOS App性能的技巧和诀窍
- 使用Bootstrap Tabs选项卡Ajax加载数据的实现以及遇到的问题;
- android自定义exittext和button
- [Leetcode]Search a 2D matrix
- HDU 5071 Chat (2014ICPC鞍山赛区现场赛B题)
- LeetCode_DP_Ugly Number II
- LeetCode_Math_Ugly Number
- LeetCode_DP_Triangle
- Gym 100341C AVL TREE(NTT快速数论变换)
- 基于Java实现的简单且通用的分页实现封装 <Pagiation>
- git 常用命令