代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
Agrb色值查看器
作者:
OliverChu
/ 发布于
2015/1/12
/
638
package com.oliver.mycolortest; import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; public class MainActivity extends ActionBarActivity implements SeekBar.OnSeekBarChangeListener { private TextView redText; private TextView greenText; private TextView blueText; private TextView alphaText; int alpha=255,red=0,green=0,blue=0; private SeekBar redBar; private SeekBar greenBar; private SeekBar blueBar; private SeekBar alphaBar; private ImageView iv; private TextView tv; private EditText hexValue; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); redText=(TextView) findViewById(R.id.redText); greenText=(TextView) findViewById(R.id.greenText); blueText=(TextView) findViewById(R.id.blueText); alphaText=(TextView) findViewById(R.id.alphaText); hexValue=(EditText) findViewById(R.id.hexValue); // hexValue.setTextColor(Color.BLUE); redBar=(SeekBar)findViewById(R.id.redBar); greenBar=(SeekBar)findViewById(R.id.gBar); blueBar=(SeekBar)findViewById(R.id.bBar); alphaBar=(SeekBar)findViewById(R.id.alphaBar); iv=(ImageView)findViewById(R.id.imageView); tv=(TextView)findViewById(R.id.colorView); redBar.setOnSeekBarChangeListener(this); greenBar.setOnSeekBarChangeListener(this); blueBar.setOnSeekBarChangeListener(this); alphaBar.setOnSeekBarChangeListener(this); Button resetBtn=(Button)findViewById(R.id.resetBtn); resetBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { red=0; green=0; blue=0; alpha=255; setAll(); } }); setAll(); tv.setTextSize(28); tv.setText("测试RGB颜色"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if(seekBar==redBar){ red=progress; setAll(); }else if(seekBar==greenBar){ green=progress; setAll(); }else if(seekBar==blueBar){ blue=progress; setAll(); }else if(seekBar==alphaBar){ alpha=progress; setAll(); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // tv.setTextColor(Color.rgb(red,green,blue)); // iv.setBackgroundColor(Color.rgb(red,green,blue)); } @Override public void onStopTrackingTouch(SeekBar seekBar) { } public void setAll(){ greenBar.setProgress(green); redBar.setProgress(red); blueBar.setProgress(blue); alphaBar.setProgress(alpha); tv.setTextColor(Color.argb(alpha, red, green, blue)); iv.setBackgroundColor(Color.argb(alpha, red, green, blue)); redText.setText("红色值= " + red + ""); greenText.setText("绿色值= "+green+""); blueText.setText("蓝色值= "+blue+""); alphaText.setText("透明度= "+alpha+""); iv.setColorFilter(Color.argb(alpha, red, green, blue)); // hexValue.setText("#"+Integer.toHexString(alpha)+Integer.toHexString(red)+Integer.toHexString(green)+Integer.toHexString(blue)); hexValue.setText(String.format("#%02x%02x%02x%02x",alpha, red, green, blue)); } } activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:id="@+id/mylayout" android:background="#ff2d2d2d" android:alwaysDrawnWithCache="false" android:animateLayoutChanges="false"> <TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="62dp" android:id="@+id/colorView" android:textColor="@android:color/holo_blue_light" /> <SeekBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/redBar" android:layout_marginTop="73dp" android:layout_below="@+id/colorView" android:max="255" android:indeterminate="false" android:progress="0" android:layout_alignRight="@+id/colorView" android:layout_alignEnd="@+id/colorView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <SeekBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/gBar" android:max="255" android:indeterminate="false" android:progress="0" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignRight="@+id/redBar" android:layout_alignEnd="@+id/redBar" /> <SeekBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/bBar" android:max="255" android:indeterminate="false" android:progress="0" android:layout_marginTop="24dp" android:layout_below="@+id/gBar" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_toLeftOf="@+id/blueText" android:layout_toStartOf="@+id/blueText" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="Small Text" android:id="@+id/redText" android:layout_alignBottom="@+id/redBar" android:layout_alignLeft="@+id/greenText" android:layout_alignStart="@+id/greenText" android:textColor="@android:color/holo_blue_light" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="Small Text" android:id="@+id/greenText" android:textColor="@android:color/holo_blue_light" android:layout_above="@+id/bBar" android:layout_toRightOf="@+id/gBar" android:layout_toEndOf="@+id/gBar" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="Small Text" android:id="@+id/blueText" android:textColor="@android:color/holo_blue_light" android:layout_alignBottom="@+id/bBar" android:layout_toRightOf="@+id/gBar" android:layout_toEndOf="@+id/gBar" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="重新设置" android:id="@+id/resetBtn" android:layout_marginBottom="46dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:theme="@android:style/Holo.Light.ButtonBar" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Design by Oliver" android:id="@+id/textView" android:textColor="@android:color/holo_orange_dark" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/imageView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:src="@drawable/ic_launcher" /> <ProgressBar style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/progressBar" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <SeekBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/alphaBar" android:max="255" android:indeterminate="false" android:progress="0" android:layout_above="@+id/resetBtn" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginBottom="21dp" android:layout_alignRight="@+id/bBar" android:layout_alignEnd="@+id/bBar" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="Small Text" android:id="@+id/alphaText" android:textColor="@android:color/holo_blue_light" android:layout_alignBottom="@+id/alphaBar" android:layout_toRightOf="@+id/alphaBar" android:layout_toEndOf="@+id/alphaBar" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:id="@+id/hexValue" android:layout_above="@+id/redText" android:layout_toRightOf="@+id/imageView" android:layout_marginBottom="22dp" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:textColor="@android:color/holo_blue_light" android:textAlignment="center" android:editable="false" android:elegantTextHeight="true" android:clickable="true" /> </RelativeLayout> AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.oliver.mycolortest" > <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
试试其它关键字
Agrb色值
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
OliverChu
贡献的其它代码
(
4
)
.
Agrb色值查看器
.
哈弗曼编码译码程序
.
双色球号码生成
.
超级菱形变色龙
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3