charmingfst/colorpicker


颜色选择

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.charmingfst:colorpicker:1.1'
	}
	dependencies {
		implementation("com.github.charmingfst:colorpicker:1.1")
	}
	<dependency>
	    <groupId>com.github.charmingfst</groupId>
	    <artifactId>colorpicker</artifactId>
	    <version>1.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.charmingfst" % "colorpicker" % "1.1"
        
        

                            
    :dependencies [[com.github.charmingfst/colorpicker "1.1"]]
        
        

Readme


colorpicker

颜色选择器

单个颜色选择器

单个颜色选择器

连续多个颜色选择器

连续多个颜色选择器,并可以反向

Usage

Step 1. Add the JitPack repository to your build file

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        compile 'com.github.charmingfst:colorpicker:1.0'
	}

Step 3. layout

<com.chm.circle.CircleColorPicker
        android:id="@+id/color_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:text="颜色"
        app:text_size="50sp"
        app:thumb="@drawable/white_ball">
</com.chm.circle.CircleColorPicker>

<com.chm.circle.IntervalColorPicker
        android:layout_width="260dp"
        android:layout_height="260dp"
        app:thumbHigh="@drawable/color_picker_high"
        app:thumbLow="@drawable/color_picker_low"
        app:interval="14"
        app:ring_breadth="10dp">
</com.chm.circle.IntervalColorPicker>

Note:

  • IntervalColorPicker没有设置默认尺寸,需要在布局文件设定宽高。
  • interval表示选择几种连续的颜色,ring_breadth表示圆环宽度。

Step 4. code

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kotlin)
        color_picker.setOnColorChangeListener { color.setBackgroundColor(it) }
    }

说明:这里使用了kotlin,代码比java简化了不少。

public void setColors(String... colors)

自定义颜色种类