Android颜色选择器_颜色选择控件源代码下载
2015-06-02 12:57:20 By: shinyuu
本Demo是使用的GBK编码的、简单的一个颜色拾取器、可选择用手指在屏幕上滑动选择颜色以及透明度、右边的长条可以显示选中的颜色、上下滑动右边的长条可以修改所选取颜色的透明度、项目注释的代码并不多、但是在每个方法的用处都是注释了的、相信使用起来问题也不大、其实就是一个自定义的view类、直接拿来调用就行了
onMeasure方法
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); if (widthMode == MeasureSpec.EXACTLY) { mWidth = width; } else { mWidth = 480; } if (heightMode == MeasureSpec.EXACTLY) { mHeight = height; } else { mHeight = 350; } LEFT_WIDTH = mWidth - SPLIT_WIDTH * 3 - RIGHT_WIDTH; setMeasuredDimension(mWidth, mHeight); }
调用方法
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.px.color.ColorPickerView android:layout_width="fill_parent" android:layout_height="350dip" /> </LinearLayout>
自定义View代码只贴出了部分、更多代码大家可以下载源代码分析一下、可以直接使用的
源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1dDk1JiT 密码: s1mm
若资源对你有帮助、浏览后有很大收获、不妨小额打赏我一下、你的鼓励是维持我不断写博客最大动力
想获取DD博客最新代码、你可以扫描下方的二维码、关注DD博客微信公众号(ddblogs)
或者你也可以关注我的新浪微博、了解DD博客的最新动态:DD博客官方微博(dwtedx的微博)
如对资源有任何疑问或觉得仍然有很大的改善空间、可以对该博文进行评论、希望不吝赐教
为保证及时回复、可以使用博客留言板给我留言: DD博客留言板(dwtedx的留言板)
感谢你的访问、祝你生活愉快、工作顺心、欢迎常来逛逛