android 使用shape使android组件呈现特殊效果

来源:互联网 发布:2017淘宝双十一红包 编辑:程序博客网 时间:2024/06/16 21:25

android 使用shape使android组件呈现特殊效果

分类: 移动开发 android开发android特效 621人阅读 评论(0)收藏 举报
androidlayoutencoding

使用到的布局文件

[java] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical"   
  6.     android:background="#ffffff"  
  7.     android:gravity="center_horizontal">  
  8.   
  9.     <TextView  
  10.         android:id="@+id/text"  
  11.         android:layout_width="wrap_content"  
  12.         android:layout_height="wrap_content"  
  13.         android:textColor="#000000"  
  14.         android:text="未使用效果"  
  15.         android:layout_marginTop="30dp"  
  16.         />  
  17.     <EditText  
  18.         android:id="@+id/edit"  
  19.         android:layout_width="280dp"  
  20.         android:layout_height="wrap_content"  
  21.         android:textColor="#000000"  
  22.         android:text="未使用效果 未使用效果 未使用效果 未使用效果 未使用效果 未使用效果"  
  23.         android:cursorVisible="true"  
  24.          />  
  25.     <TextView  
  26.         android:id="@+id/text"  
  27.         android:layout_width="wrap_content"  
  28.         android:layout_height="wrap_content"  
  29.         android:textColor="#000000"  
  30.         android:text="使用效果"  
  31.         android:layout_marginTop="10dp"  
  32.         />  
  33.     <EditText  
  34.         android:id="@+id/edit2"  
  35.         android:layout_width="280dp"  
  36.         android:layout_height="wrap_content"  
  37.         android:textColor="#000000"  
  38.         android:text="使用效果 使用效果 使用效果 使用效果 使用效果 使用效果 使用效果  使用效果"  
  39.         android:background="@drawable/shape"  
  40.         android:cursorVisible="true"  
  41.          />  
  42.       
  43.   
  44. </LinearLayout>  

使用到的shape文件 

[java] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.   
  4.     <corners  
  5.         android:radius="10dp"  
  6.         />  
  7.     <gradient   
  8.         android:startColor="#33CC00"  
  9.         android:endColor="#666600"  
  10.         android:angle="45"  
  11.         />  
  12.     <padding  
  13.         android:left="5dp"  
  14.         android:top="5dp"  
  15.         android:right="5dp"  
  16.         android:bottom="5dp"  
  17.         />  
  18.     <stroke  
  19.         android:width="3dp"  
  20.         android:color="#FF3300"  
  21.         />  
  22.       
  23. </shape>  


在这里主要说一下shape文件中各项的功能

gradient主要设置背景颜色渐变。startColor为起始颜色值,endColor为结束颜色值,angle为渐变角度

padding主要设置组件里内容距离组件内边框的间距

stroke主要设置组件的边框。width为边框宽度,color为边框颜色
原创粉丝点击