Android中圆角Button实现
来源:互联网 发布:南极人枕芯怎么样 知乎 编辑:程序博客网 时间:2024/06/04 18:10
在android开发中,Button是使用很频繁的一种控件,而android提供的原生Button是很规矩的矩形外观,有时候缺乏美感,而相反,圆角按钮则可以提升美感。那么,我们如何设计实现出圆形按钮呢?
话不多说,请看实现!
- 在drawable目录下新建名称如“shape.xml”的文件
<pre class="html" name="code"><pre class="html" name="code"><?xml version="1.0" encoding="UTF-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!-- 填充的颜色 --><solid android:color="#cfe0ef" /><!-- 弧形的半径 --><corners android:radius="100dip" /><!--文字与Button边界的间隔 --><padding android:left="40dp" android:top="40dp" android:right="40dp" android:bottom="40dp" /></shape>
- 在Layout目录下新建布局文件,引用shape.xml,见红色标注代码
<?xml version="1.0" encoding="utf-8"?><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:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="mbl.box.MainActivity" android:background="#cfe0ef"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ok" android:id="@+id/btn_ok" android:layout_marginTop="53dp" <span style="color:#cc0000;">android:background="@drawable/shape"</span> android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /></RelativeLayout>
到此,一切OK!
1 0
- Android中圆角Button实现
- Android Button实现方式
- android Button实现透明按钮
- Android Path Button效果实现
- Android代码实现自定义Button
- android 实现button双击事件
- Android实现Button点击效果
- Android xml实现Button背景图片
- Android xml实现Button背景图片
- android button 点击效果实现
- Android -- 倒计时Button的实现
- 【Android】圆角Button的实现
- android 实现button的点击
- Android通过画线实现button效果
- android 实现可拖动的Button
- Android 开发 圆角 Button 按钮 xml 实现
- android实现的圆角按钮Button
- Android开发--圆角 Button 按钮 xml 实现
- Java高级开发反射手段更换对象根节点内容
- web进修之—Hibernate起步(1)
- Arcgis server发布切片替换之前的注意事项
- Leet code 67. Add Binary
- iOS下KVO使用过程中的陷阱
- Android中圆角Button实现
- Android ViewDragHelper完全解析 自定义ViewGroup神器
- android listview 下拉头部图片拉伸
- 169. Majority Element
- CentOS 6.5下利用Rsyslog+LogAnalyzer+MySQL部署日志服务器
- 几种简单排序的实现
- Java 从流中读取byte的奇怪现象,出现负值,详解
- Android Studio通过Gradle命令来编译生成打包APK
- PAT (Top Level) Practise 1011 Cut Rectangles (35)