效果图:


第一步:
activity_main.xml ,布局代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:elevation="10dp"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerInParent="true"android:layout_marginLeft="60dp"android:background="@drawable/button_style"android:textSize="20dp"android:textColor="#fff"android:text="登录"/></RelativeLayout>

第二步:
res / drawable 右击新建自定义名为: button_style.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><!-- 蓝色阴影 --><!--android:top 顶部的偏移量--><!--android:bottom 底部的偏移量--><!--android:left 左边的偏移量--><!--android:right 右边的偏移量--><!--值越大,消失越多--><!--color 设置阴影颜色--><itemandroid:left="4dp"android:top="20dp"><shape><solid android:color="#04fcdf" /><corners android:radius="10dp" /></shape></item><!-- 白色前景       按钮背景 --><!--bottom 下边也有阴影,明显度为: 10dp--><!--right  右边也有阴影,明显度为: 20dp--><!--color 设置阴影背景色--><itemandroid:bottom="10dp"android:right="20dp"><shape><solid android:color="#FFFFFF" /><corners android:radius="10dp" /></shape></item>
</layer-list>

MainActivity 代码不变,点击运行即可!

Android Button 实现阴影边界相关推荐

  1. android button 属性,两行显示数字,前面各有图像,Android_2_常用控件及常用属性

    安卓常用控件及其常用属性 TextView android:id 这是唯一地标识控件的ID. android:capitalize 如果设置,指定该TextView中有一个文本输入法 会自动利用什么类 ...

  2. android按钮周围阴影,Android 上的按钮填充和阴影

    Android 上的按钮填充和阴影Button Padding and Shadows on Android 07/10/2018 本文内容 此 Android 平台特定控制按钮是否 :::no-lo ...

  3. android shape 画阴影_android 阴影的实现方式

    在开发过程中一般情况下,UI设计师喜欢添加一些阴影来使控件看起来比较有立体和层次感,来表明自己高大上的设计. 在这里分享下android里面关于阴影的实现方式: 1.使用.9文件 优点:个人认为最好的 ...

  4. android Button背景高度被拉伸问题--解决方案

    android Button背景高度被拉伸问题--解决方案 参考文章: (1)android Button背景高度被拉伸问题--解决方案 (2)https://www.cnblogs.com/slys ...

  5. android Button 监听的几种方式

    android button控件目前主要有如下几种监听方式: 一个button控件对应一个监听: [java] view plaincopy Button buttontest; buttontest ...

  6. android圆角布局阴影,Android 布局阴影实现

    最近项目要求,ui有很多有关于阴影的设计要求,网上找了些实现方式,但都不是很理想.现在闲下来了,就寻思着自己写个阴影布局耍耍,以备后用.先说道说道我找到的几种阴影实现方式: 系统阴影 Andorid ...

  7. Android Button监听的方式

    Android Button的几种监听方式 1.一个Button对应一个监听 1)xml文件中绑定监听 <Buttonandroid:id="@+id/btn_test"an ...

  8. android点击灰色背景图片,android button按键失去焦点和点击后改变背景图片

    android button按键得到焦点和点击后改变背景图片 我也接受android不久,今天来给同学们分享一下button得到焦点和点击后改变背景图片,其实很简单就是两个事件setOnFocusCh ...

  9. kotlin button_使用Kotlin和XML的Android Button

    kotlin button In this tutorial, we'll learn how to create a Button in Android apps using Kotlin prog ...

  10. css button阴影效果,css怎么给button设置阴影

    css给button设置阴影的方法:首先创建一个HTML示例文件:然后设置一个button按钮:最后通过给button添加"box-shadow"等属性来实现阴影效果即可. 本文操 ...

最新文章

  1. Ubuntu iso镜像文件写入U盘
  2. 从技术到科学,中国AI向何处去?
  3. 探子报!双十一紧急军情!!!
  4. python装饰器类-Python类装饰器
  5. Michael Jordan:当下的AI其实都是伪“AI”
  6. HDU3143Speedy Escape 最短路+二分+搜索
  7. Angular2.x-主/细节组件
  8. 【算法笔记】重刷PAT 题解合集
  9. 在matlab中输出、读取多个文件
  10. pta7-3 统计不及格人数_应用统计专硕院校专业难度分析【青岛大学、苏大、西安交通大学】...
  11. oracle Instance status: READY–lsnrctl status|start|stop
  12. javaScript——原型
  13. 虚拟机搭建Hadoop集群学习笔记(1)
  14. jmeter元件的作用域与执行顺序
  15. Excel自动批量发邮件
  16. RTNETLINK answers: File exists的解决方案
  17. hotmail服务器密码已修改密码,修改过密码的hotmail无法在mac和iphone上登陆和收取邮件...
  18. The operating system 'Windows Vista Version 6.1' is not supported
  19. CFileDialog类学习
  20. 基于android的资源文件管理器

热门文章

  1. 洛谷.3065.第一!First!(Trie 拓扑)
  2. php在web服务器中的工作原理
  3. Beta阶段第三次网络会议
  4. BERT中进行NER为什么没有使用CRF,我们使用DL进行序列标注问题的时候CRF是必备么?...
  5. 191030_Lda主题模型
  6. 每日算法系列【LeetCode 1363】形成三的最大倍数
  7. NLP基础—1.NLP概述
  8. pandas—pandas.DataFrame.query与pandas.DataFrame.reset_index
  9. TF-tf.keras.layers.MaxPool1D
  10. 深度学习10-tf.data-数据输入管道简介