Log.v(“ThreeTips”, ”#13”)
1 — Don’t use Color.TRANSPARENT for gradient
We all used Color.TRANSPARENT or @android:color/transparent to give view a transparency. It works in most of our cases. But when it comes to gradient, I suggest to not use these values. Let me explain. Android uses black color for these values. I mean Color.TRANSPARENT is same with transparent black. So your gradient will look little bit weird. Here is the code explains itself.
As you see from left, this is not what we want. We want to start color from green to transparent of green. But black color appears center of gradient. To solve this issue, use transparent of the start color.
Now it looks like what we want. If you need more detail about how gradients color works. Please check Bartek’s detailed tip.
2 — Stopping- Gradle Build Running (No way)
We all see that message. We expect it to stop immediately. Bu it is not. Here is a quick tip for emergency stop command for gradle build.
./gradlew --stop
3 — Difference between .commit() and .apply()?
Of course I am talking about shared preferences. I know you can replace commit() with apply() for better experience (If you are not returning boolean value from commit())
Quick answer; commit() is sync, apply() is async operation.
Detailed answer; Unlike commit(), which writes its preferences out to persistent storage synchronously, apply() commits its changes to the in-memory SharedPreferences immediately but starts an asynchronous commit to disk and you won’t be notified of any failures. If another editor on this SharedPreferences does a regular commit() while a apply() is still outstanding, the commit() will block until all async commits are completed as well as the commit itself.
Happy coding :)
References