private TextView mTextview1;
/**
- StudyRecycler
**/
@HxgBind(R.id.textview2)
private TextView mTextview2;
/**
- StudyRecycler
**/
@HxgBind(R.id.textview3)
private TextView mTextview3;
/**
- StudyRecycler
**/
@HxgBind(R.id.textview4)
private TextView mTextview4;
/**
- StudyRecycler
**/
@HxgBind(R.id.textview5)
private TextView mTextview5;
/**
- StudyRecycler
**/
@HxgBind(R.id.textview6)
private TextView mTextview6;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HxgViewUtils.getView().inject(this);
BitmapDrawable drawable = (BitmapDrawable) mImageview.getDrawable();
Bitmap bitmap = drawable.getBitmap();
//得到bitmap里面的一些色彩信息——通过Palette类分析出来的
// Palette palette = Palette.generate(bitmap);
Palette.Builder builder = Palette.from(bitmap);
builder.generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
/**
- Color.BLUE代表默认色值(分析不出来的时候的色值)
*/
//暗、柔和的颜色
int darkMutedColor = palette.getDarkMutedColor(Color.BLUE);
//亮、柔和
int lightMutedColor = palette.getLightMutedColor(Color.BLUE);
//暗、鲜艳
int darkVibrantColor = palette.getDarkVibrantColor(Color.BLUE);
//亮、鲜艳
int lightVibrantColor = palette.getLightVibrantColor(Color.BLUE);
//柔和
int mutedColor = palette.getMutedColor(Color.BLUE);
//鲜艳
int vibrantColor = palette.getVibrantColor(Color.BLUE);
/**
- 获取某种特性的颜色样品
*/
Palette.Swatch lightVibrantSwatch = palette.getVibrantSwatch();
//google推荐的:图片的整体的颜色rgb的混合值—主色调
int rgb = lightVibrantSwatch.getRgb();
//google推荐的:图片中间的文字颜色
int bodyTextColor = lightVibrantSwatch.getBodyTextColor();
//google推荐的:作为标题的颜色(有一定的和图片的对比度颜色值)
int titleTextColor = lightVibrantSwatch.getTitleTextColor();
//颜色向里
float[] hsl = lightVibrantSwatch.getHsl();
//分析该颜色在图片中所占的像素多少值
int population = lightVibrantSwatch.getPopulation();
mTextview.setBackgroundColor(getTtanslucentColor(0.6f, rgb));
mTextview.setText(“标题”);
mTextview.setTextColor(titleTextColor);
mTextview1.setBackgroundColor(darkMutedColor);
mTextview1.setText(“暗、柔和的颜色==>darkMutedColor”);
mTextview2.setBackgroundColor(lightMutedColor);
mTextview2.setText(“亮、柔和的颜色==>lightMutedColor”);
mTextview3.setBackgroundColor(darkVibrantColor);
mTextview3.setText(“暗、鲜艳的颜色==>darkVibrantColor”);
mTextview4.setBackgroundColor(lightVibrantColor);
mTextview4.setText(“亮、鲜艳的颜色==>lightVibrantColor”);
mTextview5.setBackgroundColor(mutedColor);
mTextview5.setText(“柔和的颜色==>mutedColor”);
mTextview6.setBackgroundColor(vibrantColor);
mTextview6.setText(“鲜艳的颜色==>vibrantColor”);
}
});
}
/**
-
设置背景半透明
-
@param f
-
@param rgb
-
@return
*/
private int getTtanslucentColor(float f, int rgb) {
int blue = rgb & 0xff;
int green = rgb >> 8 & 0xff;
尾声
对于很多初中级Android工程师而言,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长且无助。 整理的这些架构技术希望对Android开发的朋友们有所参考以及少走弯路,本文的重点是你有没有收获与成长,其余的都不重要,希望读者们能谨记这一点。
最后想要拿高薪实现技术提升薪水得到质的飞跃。最快捷的方式,就是有人可以带着你一起分析,这样学习起来最为高效,所以为了大家能够顺利进阶中高级、架构师,我特地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。
当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。
进阶学习视频
附上:我们之前因为秋招收集的二十套一二线互联网公司Android面试真题 (含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!
滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)
[外链图片转存中…(img-tyKRIH3y-1714790901584)]
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!