android 背景渐变色(shape,gradient)
来源:互联网 发布:淘宝店家温馨寄语 编辑:程序博客网 时间:2024/05/22 02:24
设置背景色可以通过在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)
- C# C#如何判断线程池中所有的线程是否已经完成,Backgroudworker
- A*寻路算法
- android平台linux常见编译警告提示及解决方法
- explicit构造函数
- flex 显示当前时间
- android 背景渐变色(shape,gradient)
- JS中URL中的特殊字符问题(escape,encodeURI,encodeURIComponent)
- SQL2005,2008备份集中的数据库备份与现有的 'DB' 数据库不同,错误号码:3154,解决方法
- 为S3C6410,S5PC110等ARM平台快速构建一个Meego环境
- eclipse启动参数介绍(如添加插件时,如果不显示,则使用eclipse -clean启动)
- 科目余额表 GL_BALANCE
- JS 控制文本框只能输入中文、英文、数字与指定特殊符号
- 网络字节序列,本机字节序列
- flex resize