没有合适的资源?快使用搜索试试~ 我知道了~
首页Android实现圆角Button按钮
本文实例讲述了Android开发圆角Button按钮实现过程,分享给大家供大家参考,具体内容如下 需求及效果图: 实现思路: 1、shape实现圆角 在drawable新建两个xml 文件, 这两个 xml文件用shape 实现了圆角效果。 Note: 因为要让用户有按下去的效果体验, 所有要有两套圆角图, 在按下去时候切换 <!-- res/drawable/button_shape_normal.xml --> <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rec
资源详情
资源评论
资源推荐

Android实现圆角实现圆角Button按钮按钮
本文实例讲述了Android开发圆角Button按钮实现过程,分享给大家供大家参考,具体内容如下
需求及效果图:需求及效果图:
实现思路:实现思路:
1、shape实现圆角
在drawable新建两个xml 文件, 这两个 xml文件用shape 实现了圆角效果。
Note:
因为要让用户有按下去的效果体验, 所有要有两套圆角图, 在按下去时候切换
<!-- res/drawable/button_shape_normal.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- rounded corner -->
<corners android:radius="5dp" />
<solid android:color="@color/orange_normal" />
</shape>
<!-- res/drawable/button_shape_pressed.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- rounded corner -->
<corners android:radius="5dp" />
<!-- fill with two colors, and the two colors change softly -->
<!--
<gradient
android:angle="270"
android:startColor="@color/orange_light"
android:endColor="@color/orange_normal"
android:useLevel="true" />
-->
<solid android:color="@color/orange_light" />
</shape>
2、selector实现按下效果
在 drawable 新建 一个 xml 文件, 用 selector 把刚才 建立的两个 xml 文件组织起来
<!-- res/drawable/button_shape.xml -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_shape_normal" android:state_pressed="false"/>
<item android:drawable="@drawable/button_shape_pressed" android:state_pressed="true"/>
</selector>
3、style实现多个按钮复用
在res/values/styles.xml 里面输入下面代码
<style name="SmsButton">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>











安全验证
文档复制为VIP权益,开通VIP直接复制

评论0