Android开发实例之改变背景颜色Word格式.docx

上传人:b****3 文档编号:7400733 上传时间:2023-05-08 格式:DOCX 页数:11 大小:121.42KB
下载 相关 举报
Android开发实例之改变背景颜色Word格式.docx_第1页
第1页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第2页
第2页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第3页
第3页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第4页
第4页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第5页
第5页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第6页
第6页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第7页
第7页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第8页
第8页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第9页
第9页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第10页
第10页 / 共11页
Android开发实例之改变背景颜色Word格式.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Android开发实例之改变背景颜色Word格式.docx

《Android开发实例之改变背景颜色Word格式.docx》由会员分享,可在线阅读,更多相关《Android开发实例之改变背景颜色Word格式.docx(11页珍藏版)》请在冰点文库上搜索。

Android开发实例之改变背景颜色Word格式.docx

<

?

xmlversion="

1.0"

encoding="

utf-8"

>

LinearLayoutxmlns:

android="

android:

layout_width="

fill_parent"

layout_height="

orientation="

vertical"

id="

@+id/bgll"

<

!

—-注意在此添加LinearLayout的id-->

background="

#FFFFFFFF"

<

LinearLayout

match_parent"

wrap_content"

horizontal"

>

TextView

style="

@style/alpha"

text="

@string/alpha"

layout_gravity="

center"

/>

 

SeekBar

@+id/alpha"

150dp"

layout_weight="

0.5"

max="

255"

progress="

128"

/LinearLayout>

@style/red"

@string/red"

@+id/red"

@style/green"

@string/green"

@+id/green"

@style/blue"

@string/blue"

@+id/blue"

@+id/talpha"

透明度:

/>

@+id/tred"

红色值:

@+id/tgreen"

绿色值:

@+id/tblue"

蓝色值:

@+id/tcurrent"

当前值:

颜色值:

"

textColor="

#FF000000"

textSize="

25px"

Button

@+id/btnQuit"

@string/quit"

(2)程序文件:

ChangeBGColorActivity.java

packagecom.minthen.lily;

importandroid.app.Activity;

importandroid.graphics.Color;

importandroid.os.Bundle;

importandroid.view.View;

importandroid.widget.Button;

importandroid.widget.LinearLayout;

importandroid.widget.SeekBar;

importandroid.widget.TextView;

publicclassChangeBGColorActivityextendsActivityimplements

SeekBar.OnSeekBarChangeListener{

/**Calledwhentheactivityisfirstcreated.*/

privateSeekBaralpha,red,green,blue;

privateTextViewtalpha,tred,tgreen,tblue;

privateTextViewtcurrent;

publicstaticintiAlpha,iRed,iGreen,iBlue;

privateButtonbtnQuit;

LinearLayoutbgll;

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

bgll=(LinearLayout)findViewById(R.id.bgll);

this.setTitle(R.string.title);

btnQuit=(Button)findViewById(R.id.btnQuit);

btnQuit.setOnClickListener(newButton.OnClickListener(){

@Override

publicvoidonClick(Viewarg0){

//TODOAuto-generatedmethodstub

ChangeBGColorActivity.this.finish();

}

});

alpha=(SeekBar)findViewById(R.id.alpha);

red=(SeekBar)findViewById(R.id.red);

green=(SeekBar)findViewById(R.id.green);

blue=(SeekBar)findViewById(R.id.blue);

talpha=(TextView)findViewById(R.id.talpha);

tred=(TextView)findViewById(R.id.tred);

tgreen=(TextView)findViewById(R.id.tgreen);

tblue=(TextView)findViewById(R.id.tblue);

tcurrent=(TextView)findViewById(R.id.tcurrent);

iAlpha=alpha.getProgress();

iRed=red.getProgress();

iGreen=green.getProgress();

iBlue=blue.getProgress();

alpha.setOnSeekBarChangeListener(this);

red.setOnSeekBarChangeListener(this);

green.setOnSeekBarChangeListener(this);

blue.setOnSeekBarChangeListener(this);

}

privatevoidChangeBGColor(){

tred.setText("

+iRed+"

或0x"

+Integer.toHexString(iRed));

talpha.setText("

+iAlpha+"

+Integer.toHexString(iAlpha));

tgreen.setText("

+iGreen+"

+Integer.toHexString(iGreen));

tblue.setText("

+iBlue+"

+Integer.toHexString(iBlue));

bgll.setBackgroundColor(Color.argb(iAlpha,iRed,iGreen,iBlue));

btnQuit.setTextColor(Color.argb(iAlpha,iRed,iGreen,iBlue));

btnQuit.setBackgroundColor(Color.argb(255-iAlpha,255-iRed,0xFF-iGreen,0xFF-iBlue));

tcurrent.setTextColor(Color.argb(255,255-iRed,0xFF-iGreen,0xFF-iBlue));

tcurrent.setText("

当前值:

+"

+Integer.toHexString(128)+"

\n颜色值:

+Color.argb(iAlpha,iRed,iGreen,iBlue)+"

+

"

\n或0x"

+Integer.toHexString(Color.argb(iAlpha,iRed,iGreen,iBlue)));

protectedvoidonStart(){

//TODOAuto-generatedmethodstub

super.onStart();

ChangeBGColor();

publicvoidonProgressChanged(SeekBarseekBar,intprogress,booleanarg2){

if(seekBar==alpha){

iAlpha=progress;

}

if(seekBar==red){

iRed=progress;

if(seekBar==green){

iGreen=progress;

if(seekBar==blue){

iBlue=progress;

publicvoidonStartTrackingTouch(SeekBarseekBar){

publicvoidonStopTrackingTouch(SeekBarseekBar){

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2