33 Star 88 Fork 20

zzhoujay / ColorSelector4Android

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

#ColorSelector4Android

##ColorSelector4Android是安卓平台下的颜色选择器

  • 使用Android Studio开发,依赖本库也只能在Android Studio,API等级为19
  • 已封装好Activity、DialogFragment、AlertDialog等形式供直接使用
  • 也可以直接在自己的程序里内嵌ColorPalette来使用
  • 若不需要自定义可直接依赖aar包,需自定义可导入Module:ColorPalette自行修改源码
  • 无其他依赖项

###Activity模式使用方法

启动ColorSelectActivity

    //生成一个Intent指向ColorSelectActivity
    Intent intent = new Intent(this, ColorSelectActivity.class);
    //在Intent中放入上一次的颜色数据
    intent.putExtra(ColorSelectActivity.LAST_COLOR,lastColor);
    //启动ColorSelectActivity
    startActivityForResult(intent, 0);

接收返回的数据

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                //通过ColorSelectActivity.RESULT这个键来取值
                lastColor=data.getIntExtra(ColorSelectActivity.RESULT,0x000000);
                view.setBackgroundColor(lastColor);
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

####注意在使用ColorSelectActivity时记得在自己项目的AndroidManifest文件中加入:

    <activity android:name="zhou.colorpalette.ColorSelectActivity"/>

Activity模式

###DialogFragment模式使用方法

    ColorSelectDialogFragment colorSelectDialogFragment=new ColorSelectDialogFragment();
    //设置颜色选择完成后的回调事件
    colorSelectDialogFragment.setOnColorSelectListener(new ColorSelectDialogFragment.OnColorSelectListener() {
        @Override
        public void onSelectFinish(int color) {
            lastColor=color;
            MainActivity.this.view.setBackgroundColor(lastColor);
        }
    });
    //设置上次选择的颜色(可选)
    colorSelectDialogFragment.setLastColor(lastColor);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    //需要打开时调用show方法
    colorSelectDialogFragment.show(ft, "colorSelectDialogFragment");

DialogFragment模式

###AlertDialog模式使用方法

    ColorSelectDialog colorSelectDialog = new ColorSelectDialog(this);
    //绑定颜色选择完成后的回调事件
    colorSelectDialog.setOnColorSelectListener(new ColorSelectDialog.OnColorSelectListener() {
        @Override
        public void onSelectFinish(int color) {
            // ...
        }
    });
    //设置上次的颜色(可选)
    colorSelectDialog.setLastColor(lastColor);
    //要显示Dialog时别忘了调用show方法
    colorSelectDialog.show();

ALertDialog模式

##具体操作请查看Demo

by zzhoujay

The MIT License (MIT) Copyright (c) 2015 zzhoujay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

安卓平台下的颜色选择器 展开 收起
Android
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Android
1
https://gitee.com/zzhoujay/ColorSelector4Android.git
git@gitee.com:zzhoujay/ColorSelector4Android.git
zzhoujay
ColorSelector4Android
ColorSelector4Android
master

搜索帮助