The new thing from Google - Material - talks about alpha values for black and white ... so how to convert 87% to HEX? Thanks to this guy on stackoverlfow:
100% — ff
99% — fc
98% — fa
97% — f7
96% — f5
95% — f2
94% — f0
93% — ed
92% — eb
91% — e8
90% — e6
89% — e3
88% — e0
87% — de
86% — db
85% — d9
84% — d6
83% — d4
82% — d1
81% — cf
80% — cc
79% — c9
78% — c7
77% — c4
76% — c2
75% — bf
74% — bd
73% — ba
72% — b8
71% — b5
70% — b3
69% — b0
68% — ad
67% — ab
66% — a8
65% — a6
64% — a3
63% — a1
62% — 9e
61% — 9c
60% — 99
59% — 96
57% — 94
56% — 91
56% — 8f
55% — 8c
54% — 8a
53% — 87
52% — 85
51% — 82
50% — 80
49% — 7d
48% — 7a
47% — 78
46% — 75
45% — 73
44% — 70
43% — 6e
42% — 6b
41% — 69
40% — 66
39% — 63
38% — 61
37% — 5e
36% — 5c
35% — 59
34% — 57
33% — 54
32% — 52
31% — 4f
30% — 4d
28% — 4a
28% — 47
27% — 45
26% — 42
25% — 40
24% — 3d
23% — 3b
22% — 38
21% — 36
20% — 33
19% — 30
18% — 2e
17% — 2b
16% — 29
15% — 26
14% — 24
13% — 21
12% — 1f
11% — 1c
10% — 1a
09% — 17
08% — 14
07% — 12
06% — 0f
05% — 0d
04% — 0a
03% — 08
02% — 05
01% — 03
00% — 00
Android, Java, PHP, Linux, Databases and other funny things.
I'm doing, I'm learning, I post it here.
Showing posts with label android. Show all posts
Showing posts with label android. Show all posts
Wednesday, October 22, 2014
Monday, March 10, 2014
Android EditText - hide soft keyboard on focus but keep cursor visible
In my current android app I have a lot of input fields (EditText) and I need to disable the soft keyboard on focus, because I use my own kind of input widget.
I've try several solutions, but on some was the cursor not visible or the soft keyboard was blinking on focus for some ms. But this one works:
public static void disableSoftKeyboard(final EditText v) {
if (Build.VERSION.SDK_INT >= 11) {
v.setRawInputType(InputType.TYPE_CLASS_TEXT);
v.setTextIsSelectable(true);
} else {
v.setRawInputType(InputType.TYPE_NULL);
v.setFocusable(true);
}
}
I've try several solutions, but on some was the cursor not visible or the soft keyboard was blinking on focus for some ms. But this one works:
public static void disableSoftKeyboard(final EditText v) {
if (Build.VERSION.SDK_INT >= 11) {
v.setRawInputType(InputType.TYPE_CLASS_TEXT);
v.setTextIsSelectable(true);
} else {
v.setRawInputType(InputType.TYPE_NULL);
v.setFocusable(true);
}
}
Friday, September 21, 2012
Kill Android AsyncTask if it hangs
I have an AsyncTask in my Android App that makes a network call. It may happen that the call for ever stuck. So I need a solution to handle this issue.
First I create a TimerTask that call cancel() to my AsyncTask:
class TaskKiller extends TimerTask {
private AsyncTask<?, ?, ?> mTask;
public TaskKiller(AsyncTask<?, ?, ?> task) {
this.mTask = task;
}
public void run() {
mTask.cancel(true);
}
}
Then I use this TimerTask with a timeout I need:
protected Boolean doInBackground(Object... params) {
timer.schedule(new TaskKiller(this), TIMEOUT);
// do some stuff, network, what ever can hangs
// ...
// cancel the task if all things are done
timer.cancel();
}
onCancelled() will be called if your stuff needs longer than your timeout:
protected void onCancelled() {
// do something, inform user etc.
}
Subscribe to:
Posts (Atom)