开发者社区> 科技小先锋> 正文

android之字体阴影效果

简介:
+关注继续查看

 今天刚刚好做了个字体阴影的效果,感觉加上了阴影的效果立体感十足啊!写了个简单的demo与大家分享下!
主要是以下四个属性

  android:shadowColor  阴影的颜色
  android:shadowDx       横向阴影,其值负数是往左,正数是往右
  android:shadowDy       竖直方向,其值负数是往左,正数是往右
  android:shadowRadius   阴影的半径

代码如下:

 


  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     xmlns:tools="http://schemas.android.com/tools" 
  3.     android:layout_width="match_parent" 
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical"> 
  6.  
  7.     <TextView 
  8.         android:layout_width="wrap_content" 
  9.         android:layout_height="wrap_content"  
  10.         android:shadowColor="#40000000" 
  11.         android:shadowDx="0" 
  12.         android:shadowDy="8" 
  13.         android:shadowRadius="1" 
  14.         android:layout_margin="20dip" 
  15.         android:text="底部阴影效果"  
  16.         android:textSize="20sp"/> 
  17.      
  18.      <TextView 
  19.         android:layout_width="wrap_content" 
  20.         android:layout_height="wrap_content"  
  21.         android:shadowColor="#40000000" 
  22.         android:shadowDx="0" 
  23.         android:shadowDy="-5"         
  24.         android:shadowRadius="1" 
  25.         android:layout_margin="20dip" 
  26.         android:text="顶部阴影"  
  27.         android:textSize="20sp"/> 
  28.       
  29.       
  30.       <TextView 
  31.         android:layout_width="wrap_content" 
  32.         android:layout_height="wrap_content"  
  33.         android:shadowColor="#40000000" 
  34.         android:shadowDx="-5" 
  35.         android:shadowDy="0" 
  36.         android:shadowRadius="1" 
  37.         android:layout_margin="20dip" 
  38.         android:text="左侧阴影"  
  39.         android:textSize="20sp"/> 
  40.        
  41.        
  42.        <TextView 
  43.         android:layout_width="wrap_content" 
  44.         android:layout_height="wrap_content"  
  45.         android:shadowColor="#40000000" 
  46.         android:shadowDx="5" 
  47.         android:shadowDy="0" 
  48.         android:shadowRadius="1" 
  49.        android:layout_margin="20dip" 
  50.         android:text="右侧阴影"  
  51.         android:textSize="20sp"/> 
  52.  
  53.         
  54.        <TextView 
  55.         android:layout_width="wrap_content" 
  56.         android:layout_height="wrap_content"  
  57.         android:shadowColor="#40000000" 
  58.         android:shadowDx="5" 
  59.         android:shadowDy="5" 
  60.         android:shadowRadius="1" 
  61.        android:layout_margin="20dip" 
  62.         android:text="右下侧阴影"  
  63.         android:textSize="20sp"/> 
  64. </LinearLayout> 

 

 


本文转自xuzw13 51CTO博客,原文链接:http://blog.51cto.com/xuzhiwei/1074785,如需转载请自行联系原作者

 

 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Android 自带的字体库、字体样式
Android 自带的字体库、字体样式
512 0
TextView字体加粗 ---Android基础篇
TextView字体加粗 ---Android基础篇
329 0
Android Studio 设置其整个软件平台下的背景和字体风格
Android Studio 设置其整个软件平台下的背景和字体风格
383 0
Android Studio修改字体大小
.菜单栏:File --Settings --Appearance & Behavior -- Appearance ,右边Override default fonts by(not recommended)
149 0
Android引入外部字体更改APP字体
将Android Studio切换到project形式下进入到main目录,右键新建文件夹assets,再右键新建fonts文件夹,把准备好的.ttf文件放在该文件夹下。
141 0
Android自定义TextView实现高度和宽度,解决字体适配问题
众所周知,人生是一个漫长的流程,不断克服困难,不断反思前进的过程。在这个过程中会产生很多对于人生的质疑和思考,于是我决定将自己的思考,经验和故事全部分享出来,以此寻找共鸣!!!
689 0
Android项目实战(二十三):仿QQ设置App全局字体大小
原文:Android项目实战(二十三):仿QQ设置App全局字体大小 一、项目需求: 因为产品对象用于中老年人,所以产品设计添加了APP全局字体调整大小功能。 这里仿做QQ设置字体大小的功能。    QQ实现的效果是,滚动下面的seekbar,当只有seekbar到达某一个刻度的时候,这时候上部分的效果展示部分会改变文字大小, 但是在拖动过程中字体不会改变。
1020 0
Android代码设置TextView的顶部图及设置图与字体之间距离
终于建了一个自己个人小站:https://huangtianyu.gitee.io,以后优先更新小站博客,欢迎进站,O(∩_∩)O~~ 现在很多的设计底部都是几个Tab标签,每个标签都是上边是图片,下边是文字。
2230 0
浅扒Android动态设置字体大小
说点废话 Android开发中,TextView类的控件应该说是很常用了。一般来说我们是通过android:textSize="20sp" 来设置字体大小,但是很多时候也需要动态设置字体大小,调用也很简单: textView.
1132 0
+关注
科技小先锋
文章
问答
视频
文章排行榜
最热
最新
相关电子书
更多
蚂蚁聚宝Android秒级编译——Freeline
立即下载
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
相关镜像