项目作者: krunal3kapadiya

项目描述 :
Multicolor Android RecyclerView
高级语言: Java
项目地址: git://github.com/krunal3kapadiya/Gradient-RecyclerView.git
创建时间: 2017-08-25T11:38:26Z
项目社区:https://github.com/krunal3kapadiya/Gradient-RecyclerView

开源协议:Apache License 2.0

下载


Gradient RecyclerView

Build Status
RepoSize
Languages
Twitter

Displaying gradients in each rows of RecyclerView

Screenshot

How to use? :thinking:

Use ValueInterpolator class and add this method to get the gradient for each row

  1. public int[] getGradientColors(int startColor, int endColor, int size) {
  2. int colors[] = new int[size];
  3. int startR = Color.red(startColor);
  4. int startG = Color.green(startColor);
  5. int startB = Color.blue(startColor);
  6. int endR = Color.red(endColor);
  7. int endG = Color.green(endColor);
  8. int endB = Color.blue(endColor);
  9. ValueInterpolator interpolatorR = new ValueInterpolator(0, size - 1, endR, startR);
  10. ValueInterpolator interpolatorG = new ValueInterpolator(0, size - 1, endG, startG);
  11. ValueInterpolator interpolatorB = new ValueInterpolator(0, size - 1, endB, startB);
  12. for (int i = 0; i < size; ++i) {
  13. colors[i] = Color.argb(255, (int) interpolatorR.map(i), (int) interpolatorG.map(i), (int) interpolatorB.map(i));
  14. }
  15. return colors;
  16. }

How to contribute?

Licence

  1. Copyright 2018 Krunal Kapadiya
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.