App Development

Android Development Tidbits // No. 1

android-development-tidbits-no1 blog-featured-image CF-510x295

Today, we are excited to kick off the Android Development Tidbits series on the blog. The Android team at WillowTree has a tradition of sharing quick lessons we call “tidbits” on our Slack channel throughout the week, and now we’ll be posting some of those tidbits to the blog for you.

We encourage everyone to tidbit as much as they want throughout the week (even if a tidbit seems obvious) because it might help someone later. Some of the tidbits you will already know and some of them you won’t. Either way, we hope the information we share here helps you improve your coding skills and that you enjoy our first collection of tidbits. Feel free to leave us your questions and comments.

Tidbit One

Did you know that AndroidStudio has an asset generator for stock actionbar icons? Just go to:

[File] >[New] >[Image Asset]

From there, select “Clipart” for easy stock components. Doing this gives your designer one less thing to worry about, and it gives you just enough time to fix that padding issue you’ve been ignoring. You know…that one. blog-post-image android-tidbits CF-398x282@2x

Tidbit 2

Do you have a reason to run an individual Gradle test? Just run:

./gradlew testDebug --tests='\*.<testname>'

Tidbit 3

Use strict mode to make sure you aren’t doing things on the main thread you shouldn’t be. Remember to turn this off in release though, it can have performance implications itself, causing crashes if you leave it configured that way. http://developer.android.com/reference/android/os/StrictMode.html

if (BuildConfig.DEBUG) {
 StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
       .detectAll()
       .penaltyLog()
       .build());
 StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
       .detectAll()
       .penaltyLog()
       .penaltyDeathOnNetwork()
       .build());
}

Tidbit 4:

You can set a RequestTransformer on Picasso to modify the request url. For example, adding image width and height url parameters.

Tidbit 5:

if you set android:windowSoftInputMode="adjustResize" for an activity in the manifest, then a ScrollView (or other collapsable ViewGroups) will shrink to accommodate the soft keyboard. But, if you set android:windowFullscreen="true" in the activity’s theme, then the ScrollView won’t shrink because it’s forced to fill the whole screen. However, setting ndroid:fitsSystemWindows="false" in your theme also causes adjustResize not to work.

Quickstart-Guide-to-Kotlin-Multiplatform

A Quick Start Guide to Kotlin Multiplatform

Kotlin Multiplatform, though still experimental, is a great up-and-coming solution...

Read the article