Mapping iOS Assets to Android

So I’ve got a sweet new job working for Beachbody. We make awesome products like P90X and Brazil Butt Lift. We also make mobile apps. They hired me to essentially port their P90X iOS app to Android.

I’m in the planning stages right now and one of the challenges I’m facing is how to map the existing iOS asset classes to their appropriate Android asset classes. For iOS, it’s still pretty easy, you just have at most three classes of assets to worry about:

  • Small = 480 x 320 (163 dpi)
  • Large = 960 x 640 (326 dpi)
  • Tall = 1136 x 640 (326 dpi)

For Android, you have the following screen sizes classes:

  • Small = at least 426dp x 320dp
  • Medium = at least 470dp x 320dp
  • Large = at least 640dp x 480dp
  • xLarge = at least 960dp x 720dp

Then, you also have different density classes:

  • ldpi = low density (~120dpi)
  • mdpi = medium (baseline) density (~160dpi)
  • hdpi = high density (~240dpi)
  • xhdpi = extra high density (~320dpi)
Looking at this data, if you don’t have the resources to create assets for every Android density class (ldpi, mdpi, hdpi, xhdpi), it looks the following mappings make sense:
  • Small iOS images should work for ldpi and mdpi Android devices.
  • Large iOS images should work for hdpi and xhdpi Android devices.

Unless I hear about a better solution, this will the strategy I’m taking. Please comment on this post if you have any feedback or input! Cheers!

Android: How to Programmatically Lock the Orientation

In mobile application development, there may be times when you want certain screens within your app to always show in landscape or in portrait mode. Android makes this easy to do within your Activity class:

import android.content.pm.ActivityInfo;
...
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

You can also set this in the manifest:

<activity android:name=".YourActivity"
              android:label="@string/app_name"
              android:screenOrientation="landscape">

Android Selectors

Android selectors can be used to give your Buttons or images the feeling that they are being pressed. Essentially, a selector defines a different drawable for different states of an image or Button. Selector files should reside in the /res/drawable/ folder in your project. Here’s what a basic selector looks like:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
        android:drawable="@drawable/button_state_pressed" />
    <item android:state_focused="true"
         android:drawable="@drawable/button_state_focused" /> 
    <item android:drawable="@drawable/button_state_normal" /> 
</selector>

If this XML resided in /res/drawable/imagebutton_selector, for example you’d set the android:src attribute of your button to android:src=”@drawable/imagebutton_selector”.

What is Eurocurrency?

It’s a common misconception that Eurocurrency has to be the deposit of foreign currency in a European bank. In fact, Eurocurrency is considered a deposit any currency in an international bank located in a different country from the deposited money.

Eurocurrency got it’s start back in the Soviet communist days. Back then, Communist countries were afraid to deposit their US dollars in US banks for fear their assets would be frozen our stripped (due to anti-Communist) sentiment. They chose to deposit their US dollars in a French bank whose telex address happen to be EURO-BANK. That’s why we call it Eurocurrency!

Since the advent of the European Union and the euro, however, we have started to call Eurocurrency simply international currency. Also, instead of the term Eurobank, we now use the term prime bank. I think this makes more sense.

When a Eurobank, or prime bank, makes a short to medium-term loan, we call this appropriately a Eurocredit. These loans would be loans in currencies other than the currency of the home country of the lending bank.