Skip to content

Commit 777391c

Browse files
committed
Merge pull request tangqi92#11 from troyliu0105/master
remove or add some unavailable links to Content
2 parents 2113caf + 1b01440 commit 777391c

13 files changed

+434
-65
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
Utils/URLChecker/out
22
Utils/URLChecker/*.class
3+
Utils/.idea
4+
Utils/Utils.iml
5+
Utils/out

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
你可以通过 [Pull requests](https://github.com/tangqi92/Android-Tips/pulls) 的形式进行提交,当然也欢迎 `Star``Fork` :)
1212

13+
>由于各种问题,给出的链接可能会无法正常访问。遇到这种情况欢迎大家提交[Issue](https://github.com/tangqi92/Android-Tips/issues),Contributers也可以使用[Utils](https://github.com/tangqi92/Android-Tips/tree/master/Utils)里面的[URLChecker](https://github.com/tangqi92/Android-Tips/blob/master/Utils/URLCheckerREADME.md)来检测这个README.md下面的链接有效性,你可以选择更改为新的有效连接,或者把需要梯子的文章以Markdown的形式保存在Utils/Content目录下,并注明原文章链接和作者。
14+
1315
>由于本项目面向的群体为初学者,所以列表的知识点以初级为主,资源大多数为中文,如遇到少数无法访问的情况,请自备梯子。
1416
1517
---
@@ -69,7 +71,7 @@
6971
1. [android进程间通信:使用AIDL](http://blog.csdn.net/saintswordsman/article/details/5130947)
7072
2. [Android AIDL使用详解](http://blog.csdn.net/stonecao/article/details/6425019)
7173
3. [android跨进程通信(IPC): 使用AIDL](http://blog.csdn.net/singwhatiwanna/article/details/17041691)
72-
4. [Android中的跨进程通信的实现(一)——远程调用过程和aidl](http://foocoder.com/blog/androidzhong-de-kua-jin-cheng-tong-xin-de-shi-xian-(%5B%3F%5D-)-yuan-cheng-diao-yong-guo-cheng-he-aidl.html/)
74+
4. [Android中的跨进程通信的实现(一)——远程调用过程和aidl](http://blog.csdn.net/notice520/article/details/8135600)
7375
5. [Android Studio下如何配置AIDL文件](http://chenqichao.me/2014/05/13/003-Android-Studio-AIDL/)
7476

7577
### Android-Async-Http
@@ -125,7 +127,7 @@
125127
### Configuration Change
126128

127129
1. [Android Configuration change引发的问题及解决方法](http://blog.csdn.net/aliaooooo/article/details/23606179?utm_source=tuicool)
128-
2. [Handling Runtime Changes](http://developer.android.com/guide/topics/resources/runtime-changes.html)
130+
2. [Handling Runtime Changes](https://github.com/troyliu0105/Android-Tips/blob/master/Utils/Content/Handing_Runtime_Changes.md)
129131

130132
### Context
131133

@@ -218,8 +220,7 @@
218220

219221
### Immersive Full-Screen Mode
220222

221-
1. [Using Immersive Full-Screen Mode](https://developer.android.com/training/system-ui/immersive.html)
222-
2. [全屏沉浸式应用](http://hukai.me/android-training-course-in-chinese/ui/system-ui/immersive.html)
223+
1. [Using Immersive Full-Screen Mode](https://developer.android.com/training/system-ui/immersive.html) [**译文**](http://hukai.me/android-training-course-in-chinese/ui/system-ui/immersive.html)
223224

224225
### Intent
225226

@@ -309,7 +310,7 @@
309310
### Palette
310311

311312
1. [Extracting Colors to a Palette with Android Lollipop](https://www.bignerdranch.com/blog/extracting-colors-to-a-palette-with-android-lollipop/)
312-
2. [Android Lollipop 新特性 - Palette](http://baoyz.com/android/2014/10/21/android-palette-use/)
313+
2. [Android Lollipop 新特性 - Palette](https://github.com/troyliu0105/Android-Tips/blob/master/Utils/Content/Android_Lollipop_%E6%96%B0%E7%89%B9%E6%80%A7-Palette.md)
313314

314315
### Preference
315316

@@ -338,7 +339,7 @@
338339
4. [Android-RecyclerView-Item点击事件设置](http://blog.csdn.net/guxiao1201/article/details/40423361)
339340
5. [Why doesn't RecyclerView have onItemClickListener()? And how RecyclerView is different from Listview?](http://stackoverflow.com/questions/24885223/why-doesnt-recyclerview-have-onitemclicklistener-and-how-recyclerview-is-dif)
340341
6. [Create RecyclerView with multiple view type](http://doublewong.com/2014/create-recyclerview-with-multiple-view-type/)
341-
7. [Simple RecyclerView Divider](https://gist.github.com/polbins/e37206fbc444207c0e92)
342+
7. [Simple RecyclerView Divider](https://github.com/troyliu0105/Android-Tips/blob/master/Utils/Content/Simple_RecyclerView_Divider.md)
342343

343344
### RandomAccessFile
344345

@@ -431,7 +432,6 @@
431432
1. [ViewPager + Fragment实现滑动标签页](http://blog.csdn.net/lizhenmingdirk/article/details/13631813)
432433
2. [【移动开发】Android中Fragment+ViewPager的配合使用](http://smallwoniu.blog.51cto.com/3911954/1322746)
433434
3. [Android 手把手教您自定义ViewGroup(一)本文出自:【张鸿洋的博客】](http://blog.csdn.net/lmj623565791/article/details/38339817)
434-
4.
435435

436436
### View
437437

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[原文链接](http://baoyz.com/android/2014/10/21/android-palette-use/) (*需要科学上网*)
2+
3+
## Android Lollipop 新特性 - Palette
4+
5+
> *Palette 可以从一张图片中提取颜色,我们可以把提取的颜色融入到App UI中,可以使UI风格更加美观融洽。比如,我们可以从图片中提取颜色设置给ActionBar做背景颜色,这样ActionBar的颜色就会随着显示图片的变化而变化。*
6+
7+
Palette可以提取的颜色如下:
8+
+ Vibrant (有活力的)
9+
+ Vibrant dark(有活力的 暗色)
10+
+ Vibrant light(有活力的 亮色)
11+
+ Muted (柔和的)
12+
+ Muted dark(柔和的 暗色)
13+
+ Muted light(柔和的 亮色)
14+
15+
### 使用方法
16+
17+
> *我们要想使用Palette,需要导入Palette的兼容库,`Gradle` 中添加下面依赖。*
18+
19+
```
20+
compile 'com.android.support:palette-v7:21.0.0'
21+
```
22+
23+
第一步,我们需要通过一个Bitmap对象来生成一个对应的Palette对象。
24+
Palette 提供了四个静态方法用来生成对象。
25+
26+
+ `Palette generate(Bitmap bitmap)`
27+
+ `Palette generate(Bitmap bitmap, int numColors)`
28+
+ `generateAsync(Bitmap bitmap, PaletteAsyncListener listener)`
29+
+ `generateAsync(Bitmap bitmap, int numColors, final PaletteAsyncListener listener)`
30+
31+
> *不难看出,生成方法分为`generate`(同步)和`generateAsync`(异步)两种,如果图片过大使用generate方法,可能会阻塞主线程,我们更倾向于使用`generateAsync`的方法,其实内部就是创建了一个`AsyncTask``generateAsync`方法需要一个`PaletteAsyncListener`对象用于监听生成完毕的回调。除了必须的`Bitmap`参数外,还可以传入一个`numColors`参数指定颜色数,默认是 16。*
32+
33+
第二步,得到Palette对象后,就可以拿到提取到的颜色值
34+
35+
+ `Palette.getVibrantSwatch()`
36+
+ `Palette.getDarkVibrantSwatch()`
37+
+ `Palette.getLightVibrantSwatch()`
38+
+ `Palette.getMutedSwatch()`
39+
+ `Palette.getDarkMutedSwatch()`
40+
+ `Palette.getLightMutedSwatch()`
41+
42+
第三步,使用颜色,上面get方法中返回的是一个 `Swatch` 样本对象,这个样本对象是Palette的一个内部类,它提供了一些获取最终颜色的方法。
43+
44+
+ `getPopulation()`: 样本中的像素数量
45+
+ `getRgb()`: 颜色的RBG值
46+
+ `getHsl()`: 颜色的HSL值
47+
+ `getBodyTextColor()`: 主体文字的颜色值
48+
+ `getTitleTextColor()`: 标题文字的颜色值
49+
50+
> *通过 `getRgb()` 可以得到最终的颜色值并应用到UI中。`getBodyTextColor()``getTitleTextColor()` 可以得到此颜色下文字适合的颜色,这样很方便我们设置文字的颜色,使文字看起来更加舒服。*
51+
52+
### 实例代码
53+
54+
```java
55+
// 此方法可能会阻塞主线程,建议使用异步方法
56+
Palette palette = Palette.generate(bitmap);
57+
// 异步提取Bitmap颜色
58+
Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
59+
@Override
60+
public void onGenerated(Palette palette) {
61+
// 提取完毕
62+
// 有活力的颜色
63+
Palette.Swatch vibrant = palette.getVibrantSwatch();
64+
// 有活力的暗色
65+
Palette.Swatch darkVibrant = palette.getDarkVibrantSwatch();
66+
// 有活力的亮色
67+
Palette.Swatch lightVibrant = palette.getLightVibrantSwatch();
68+
// 柔和的颜色
69+
Palette.Swatch muted = palette.getMutedSwatch();
70+
// 柔和的暗色
71+
Palette.Swatch darkMuted = palette.getDarkMutedSwatch();
72+
// 柔和的亮色
73+
Palette.Swatch lightMuted = palette.getLightMutedSwatch();
74+
 
75+
// 使用颜色
76+
// 修改Actionbar背景颜色
77+
getActionBar().setBackgroundDrawable(new ColorDrawable(vibrant.getRgb()));
78+
// 修改文字的颜色
79+
mTextView.setTextColor(vibrant.getTitleTextColor());
80+
...
81+
// 根据需求选择不同效果的颜色应用
82+
});
83+
```
84+
85+
### 效果
86+
87+
![pic](https://raw.githubusercontent.com/baoboy/baoboy.github.io/master/images/screenshots/palette_3.png)
88+
89+
### 代码下载
90+
91+
[https://github.com/baoyongzhang/android-lollipop-samples](https://github.com/baoyongzhang/android-lollipop-samples)中的[palette-sample](https://github.com/baoyongzhang/android-lollipop-samples/tree/master/palette-sample)

0 commit comments

Comments
 (0)