• GRAPEFRUIT # ED5565,# DA4453
  • BITTERSWEET # FC6E51,# E9573F
  • SUNFLOWER # FFCE54,# F6BB42
  • GRASS # A0D468,# 8CC152
  • MINT # 48CFAD,# 37BC9B
  • AQUA # 4FC1E9,# 3BAFDA
  • BLUE JEANS # 5D9CEC,# 4A89DC
  • LAVANDER # AC92EC,# 967ADC
  • PINK ROSE # EC87C0,# D770AD
  • LIGHT GRAY # F5F7FA,# E6E9ED
  • MEDIUM GRAY # CCD1D9,# AAB2BD
  • DARK GRAY # 656D78,# 434A54

不透明度16进制值

不透明度 16进制值
100% FF
95% F2
90% E6
85% D9
80% CC
75% BF
70% B3
65% A6
60% 99
55% 8C
50% 80
45% 73
40% 66
35% 59
30% 4D
25% 40
20% 33
15% 26
10% 1A
5% 0D
0% 00

  • listview的item可选的背景
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 默认时的背景背景 -->
<item android:drawable="@drawable/pic1" />
<!-- 没有焦点时的背景图片 -->
<item android:state_window_focused="false" android:drawable="@drawable/pic1" />
<!-- 非触摸模式下获得焦点并单击时的背景图片 -->
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/pic2" />
<!-- 触摸模式下单击时的背景图片 -->
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pic3" />
<!-- 选中时的图片背景 -->
<item android:state_selected="true" android:drawable="@drawable/pic4" />
<!-- 获得焦点时的图片背景 -->
<item android:state_focused="true" android:drawable="@drawable/pic5" />

在listView中配置android:listSelector="@drawable/list_item_bg"或者在item中添加android:background="@drawable/list_item_bg"即可实现,或者在java代码中使用Drawable drawable = getResources().getDrawable(R.drawable.list_item_bg);,listView.setSelector(drawable);。可能出现列表出现黑的情况,加上android:cacheColorHint="@android:color/transparent"

  • button的可选背景
    • android:state_selected 为选中
    • android:state_focused 获得焦点
    • android:state_pressed 点击
    • android:state_enable 是否响应事件,指所有事件
      <?xml version="1.0" encoding="utf-8"?>
      <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_selected="true" android:color="# FFF" />
      <item android:state_focused="true" android:color="FFF" />
      <item android:state_pressed="true" android:color="# FFF" />
      <item android:color="# 000" />
      </selector>
      

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
public class PixelUtils {
private static Context mContext = MyApplication.getInstance();

// dp->px
public static int dp2px(float value) {
final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
return (int) (value * (scale / 160) + 0.5f);
}
// dp->px
public static int dp2px(float value, Context context) {
final float scale = context.getResources().getDisplayMetrics().densityDpi;
return (int) (value * (scale / 160) + 0.5f);
}
// px->dp
public static int px2dp(float value) {
final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
return (int) ((value * 160) / scale + 0.5f);
}
// px->dp
public static int px2dp(float value, Context context) {
final float scale = context.getResources().getDisplayMetrics().densityDpi;
return (int) ((value * 160) / scale + 0.5f);
}
// sp->px
public static int sp2px(float value) {
Resources r;
if (mContext == null) {
r = Resources.getSystem();
} else {
r = mContext.getResources();
}
float spvalue = value * r.getDisplayMetrics().scaledDensity;
return (int) (spvalue + 0.5f);
}
// sp->px
public static int sp2px(float value, Context context) {
Resources r;
if (context == null) {
r = Resources.getSystem();
} else {
r = context.getResources();
}
float spvalue = value * r.getDisplayMetrics().scaledDensity;
return (int) (spvalue + 0.5f);
}
// px->sp
public static int px2sp(float value) {
final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
return (int) (value / scale + 0.5f);
}
// px->sp
public static int px2sp(float value, Context context) {
final float scale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (value / scale + 0.5f);
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
public class PerferencesUtils {
public static String PREFERENCE_NAME = "MYPERFERENCERS";

public static boolean putString(Context context,String key,String value) {
SharedPreferces settings = context.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE);
SharedPreferces.Editor = settings.edit();
editor.putString(key,value);
return editor.commit();
}

public static String getString(Context context,String key) {
return getString(context,key,null);
}

public static String getString(Context context,String key,String defaultValue) {
SharedPreferces settings = context.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE);
return settings.getString(key,defaultValue);
}

public static boolean putInt(Context context,String key,int value) {
SharedPreferces settings = context.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE);
SharedPreferces.Editor = settings.edit();
editor.putInt(key,value);
return editor.commit();
}

public static int getInt(Context context,String key) {
return getInt(context,key,-1);
}

public static int getInt(Context context,String key,int defaultValue) {
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE);
return settings.getInt(key,defaultValue);
}

public static putLong(Context context,String key,long value) {
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putLong(key,value);
return editor.commit();
}

public static long getLong(Context context, String key) {
return getLong(context, key, -1);
}

public static long getLong(Context context, String key, long defaultValue) {
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getLong(key, defaultValue);
}

public static boolean putFloat(Context context, String key, float value) {
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(key, value);
return editor.commit();
}

public static float getFloat(Context context, String key) {
return getFloat(context, key, -1);
}

public static float getFloat(Context context, String key, float defaultValue) {
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getFloat(key, defaultValue);
}

public static boolean putBoolean(Context context, String key, boolean value) {
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(key, value);
return editor.commit();
}

public static boolean getBoolean(Context context, String key) {
return getBoolean(context, key, false);
}

public static boolean getBoolean(Context context, String key,
boolean defaultValue) {
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getBoolean(key, defaultValue);
}

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
public class RandomUtils {
// 制定字符串范围的因子
public static final String NUMBERS_AND_LETTERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String NUMBERS = "0123456789";
public static final String LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String CAPITAL_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz";
// 获取随机数字、字母字符串
public static String getRandomNumbersAndLetters(int length) {
return getRandom(NUMBERS_AND_LETTERS, length);
}
// 获取随机数字字符串
public static String getRandomNumbers(int length) {
return getRandom(NUMBERS, length);
}
// 获取英文字母组成的随机字符串
public static String getRandomLetters(int length) {
return getRandom(LETTERS, length);
}
// 获取大写字母组成的随机字符串
public static String getRandomCapitalLetters(int length) {
return getRandom(CAPITAL_LETTERS, length);
}
// 获取小写字母组成的随机字符串
public static String getRandomLowerCaseLetters(int length) {
return getRandom(LOWER_CASE_LETTERS, length);
}
// 获取制定字符串和长度的随机字符串
public static String getRandom(String source, int length) {
return TextUtils.isEmpty(source) ? null : getRandom(
source.toCharArray(), length);
}
// 获取制定字符数组和长度的随机字符串
public static String getRandom(char[] sourceChar, int length) {
if (sourceChar == null || sourceChar.length == 0 || length < 0) {
return null;
}

StringBuilder str = new StringBuilder(length);
Random random = new Random();
for (int i = 0; i < length; i++) {
str.append(sourceChar[random.nextInt(sourceChar.length)]);
}
return str.toString();
}

// 获取0~max范围的随机int
public static int getRandom(int max) {
return getRandom(0, max);
}

// 获取min~max范围的随机int
public static int getRandom(int min, int max) {
if (min > max) {
return 0;
}
if (min == max) {
return min;
}
return min + new Random().nextInt(max - min);
}

}

序列化工具类,用于序列化对象对文件或从文件反序列化对象

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class Serialization(String filePath) {
public static Object deserialization(String filePath){
ObjectInputStream in = null;
try {
in = new ObjectInputStream(new FileInputStream(filePath));
Object o = in.readOject();
in.close();
return o;
} catch (FileNotFoundException e) {
throw new RuntimeException("FileNotFoundException occurred. ", e);
} catch (ClassNotFoundException e) {
throw new RuntimeException("ClassNotFoundException occurred. ", e);
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
}
}
}
}

public static void serialization(String filePath,Object obj) {
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(new fileOutputStream(filePath));
out.writeObject(obj);
out.close();
} catch (FileNotFoundException e) {
throw new RuntimeException("FileNotFoundException occurred. ", e);
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
}
}
}
}
}

工具类,用于读取资源目录下的内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
public class ResourceUtils {
// 读取assets目录下某个文件内容
public static String getFileFromAssets(Context context,String fileName){
if(context == null || TextUils.isEmpty(fileName)) {
return null;
}
StringBuilder s = new StringBuilder("");
try {
InputStreamReader in = new InputStreamReader(context.getResources().getAssets().open(fileName));
BufferedReader br = new BufferedReader(in);
String line;
while ((line = br.readLine()) != null){
s.append(line);
}
return s.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
// 读取raw目录下某个文件内容
public static String getFileFromRaw(Context context,int resId) {
if (context == null) {
return null;
}

StringBuilder s = new StringBuilder();
try {
InputStreamRead in = new InputStreamReader(context.getResources().openRawResource(resId));
BufferedReader br = new BufferedReader(in);
String line;
while ((line = br.readLine() != null)){
s.append(line);
}
return s.toString();
} catch (IOException e) {
e.printStatckTrace();
return null;
}
}

public static List<String> getFileToListFromAssets(Context context,String fileName) {
if (context == null || TextUtils.isEmpty(fileName)) {
return null;
}
List<String> fileContent = new ArrayList<String>();
try {
InputStreamReader in = new InputStreamReader(context.getResouces().getAssets().open(fileName));
BufferedReader br = new BufferedReader(in);
String line;
while((line = br.readLine() != null)) {
fileContent.add(line);
}
br.close();
return fileContent;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

public static List<String> getFileToListFromRaw(Context context,int resId) {
if (context == null) {
return null;
}
List<String> fileContent = new ArrayList<String> ();
BufferedReader reader = null;
try {
InputStreamReader in = new InputStreamReader(context.getResouces().openRawResource(resId));
reader = new BufferedReader(in);
String line = null;
while((line = reader.readLine()) != null){
fileContent.add(line);
}
reader.close();
return fileContent;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}

SockMonitor可以捕捉PC上进程的网络访问,小米助手可以为小米手机USB共享网络提供,其实可以设置IP代理的方法,但是直接这样太方便了。

设置

连接手机后设置共享网络,注意断开手机的3G、wifi信号
在防火墙中->允许程序或功能通过Windows防火墙->将ScockMonitor添加到其中

过滤

在ScockMoniter中设置过滤器通过限制MiPoneManager这个进程就可以只抓取手机网络访问数据
在限定IP即可抓取指定IP的数据