4. We're in a whole new place.
Bring the right stuff aboard.
Space Chips
http://moto.ly/spacechips
5. Get the magic
01 KEEP ERGONOMICS THOUGHTFUL
02 ENGAGE THE SENSES
03 USE COOL AESTHETICS
04 MAKE IT OBVIOUS
6. Get the magic
01 KEEP ERGONOMICS THOUGHTFUL
Landscape layouts
Rich notifications
Text sizes
02 ENGAGE THE SENSES
Images
Touchability
03 USE COOL AESTHETICS
Themes, themes, themes
04 MAKE IT OBVIOUS
Action bars
Fragments
Drag and drop
29. Images
Choose an image strategy
One set of images and let Android autoscale?
Custom resource sets for different sizes and densities?
Target the most commonly used density?
Retrieve images dynamically at runtime and scale for the device?
30. Images
Memory vs file size – an example
Autoscaling 32 MB memory
324 KB size
Image sets 23 MB memory
728 KB size
36. Touchability
Make sure all targets are tappable
public View getView( int position,
View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext);
i.setImageResource(mImageIds[position]);
i.setLayoutParams(new Gallery.LayoutParams(
300, 200));
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setBackgroundResource(
mGalleryItemBackground);
return i;
}
41. Themes
But they require hardware acceleration
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:hardwareAccelerated="true" >
Only available with Honeycomb
42. Themes
But you might be targeting multiple Android versions
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="11" />
49. Action bars
Step 2 – Place menu items on action bar
<item android:id="@+id/favorite"
android:title="@string/favorite"
android:icon="@drawable/ic_menu_star"
android:showAsAction="ifRoom" />
50. Action bars
Step 3 - Handle options selection as usual
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.favorite:
// do something
return true;
…
}
52. Action bars
Get some magic, style it
<style name="MyTheme"
parent="android:style/Theme.Holo" >
<item name="android:actionBarStyle">
@style/ActionBar</item>
</style>
<style name="ActionBar"
parent="android:style/Widget.Holo.ActionBar">
<item name="android:background">
@drawable/my_background</item>
</style>
53. Action bars
Get some magic, add a dialog
Use AlertDialog.Builder
Create a custom dialog in XML
Use a DialogFragment
54. Action bars
But do Honeycomb stuff only on Honeycomb
private static boolean isHoneycomb =
android.os.Build.VERSION.SDK_INT > 10;
if (isHoneycomb) {
// build custom dialog here
}
59. Fragments
In your main activity, find your fragments
Fragment gridFrag =
getFragmentManager().
findFragmentById(R.id.photogrid);
Fragment photoFrag =
getFragmentManager().
findFragmentById(R.id.the_frag);
60. Fragments
Check the orientation and adjust the views
private boolean photoInline = false;
photoInline = (photoFrag != null &&
getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE);
if (photoInline) {
// do something
} else if ( photoFrag != null ) {
getView().setVisibility(View.GONE);
}