android 背景渐变色

android 背景渐变色


2024年7月3日发(作者:)

android 背景渐变色(shape,gradient)

设置背景色可以通过在res/drawable里定义一个xml,如下:

android:startColor="#FFF"

android:endColor="#000"

android:angle="45"

/>

shape是用来定义形状的,gradient定义该形状里面为渐变色填充,startColor起始

颜色,endColor结束颜色,angle表示方向角度。当angle=0时,渐变色是从左向右。 然

后逆时针方向转,当angle=90时为从下往上。

实现过程:

第一步:

res/drawable/background_

android:startColor="#FFF"

android:endColor="#000"

android:angle="45"

/>

第二步:

res/layout/

xmlns:android="/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/background_login">

第三步:

import ty;

import ;

public class LoginActivity extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

te(savedInstanceState);

setContentView();

}

}

效果图:


发布者:admin,转转请注明出处:http://www.yc00.com/web/1719964929a2759451.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信