android 背景渐变色(shape,gradient)
来源:互联网 发布:华中师范网络教育登陆 编辑:程序博客网 时间:2024/05/16 11:13
设置背景色可以通过在res/drawable里定义一个xml,如下:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#FFF" android:endColor="#000" android:angle="45" /></shape>
shape是用来定义形状的,gradient定义该形状里面为渐变色填充,startColor起始颜色,endColor结束颜色,angle表示方向角度。当angle=0时,渐变色是从左向右。 然后逆时针方向转,当angle=90时为从下往上。
实现过程:
第一步:
res/drawable/background_login.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#FFF" android:endColor="#000" android:angle="45" /></shape>
第二步:
res/layout/login.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_login"> </LinearLayout>
第三步:
import android.app.Activity;import android.os.Bundle;public class LoginActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); }}
效果图:
- 1. android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- Android背景渐变色(shape,gradient)
- 线程研究:(一)单线程编程 .net 2
- 三种内存释放模式
- vmware 修改磁盘空间
- oracle SQL语句
- python3之字节码编译
- android 背景渐变色(shape,gradient)
- 一般图搜索算法
- [Tips] cmd中粘贴的快捷键
- EXCEL中两列合并成一列以及根据相同列的值将表中一列的值复制到另一张表中?
- 字符串指针和字符数组的区别
- 嵌入式开发用到的工具--TFTP
- STL vector 容器介绍
- 如何清空gridview的数据
- C自定义头文件调用外部函数——简单排序