Tuesday, March 29, 2011

Running my app on Honeycomb - why these changes?

My boss bought a Xoom tablet. Pretty sweet device. I have played with the Samsung Tablet a couple of times and I like it too. I have not played with an iPad, I have only seen them for a brief period of time. Makes me pine for one of my own but of course they sold out the WiFi only version rather quickly.

I have installed our software on the Samsung 7" tablet and it ran without a hitch. Of course that is running 2.2 and really is just a big version of a phone. I was expecting the same to happen on the Xoom but I was wrong.

I had to install the Motorola USB device driver first. No big deal. I now have a variety of USB drivers on my development box as I have installed our app on my T-Mobile Samsung Galaxy S, a Verizon phone, an HTC and some others. After that we kicked it into dev mode and moved the software across then things got ugly.

I am using a pretty simple Relative Layout View in a List Activity and two simple views (with some minor special variations) in an Expandable List View. Both looked crappy, labels on top of things, other areas to tall and some layouts just missing data / not sized properly at all.

First up I was creating the Group header view in code for the Expandable List View. I was not using DIP but a hard coded number. This is the wrong way to do Android programming. I was using sample code from the web. I had converted the Items of the Expandable list to XML so I converted this area also quickly solving that issue. I thought this area looked a little off when I ran it in the 1.6 emulator at one time. Both the 1.6 emulator and the Xoom use 160 dpi instead of the 240 dpi of my phone. I should have fixed this earlier.

Next was the labels on top of each other. Turns out the layout_below setting works differently in Honeycomb. I had this type of layout

label1:  data1
label2: data2   label3: data3

I had label2, data2, label3 and data3 using layout_below="@id/label1" which worked for label2 but maybe not for data2 and for sure not for label3 and data3. I used layout_alignBaseline instead to align data2, label3 and data3 to label2 and now it seems to look as it should on all platforms if you do the next step.

Honeycomb does not consider "" to be the same as " " when it comes to control height sizing. If you give it the empty string "" it thinks the size of the area is really small. If you give it " " (notice the SPACE in there) it will correctly calculate font sizes for the TextView. Very annoying and I really don't have a clue why they decided to do this. I understand when things are NULL vs. "" or " " but that control has a font size so I should get back metrics for the font being used not the content and "" should give same results as " " as it has for a long time on the Android platform. I had to adjust all the display items in my Map converting "" to " " as I found them. Small waste of processing time but I decided not to do an OS version check.

For the Item view in the Expandable List View I had to change from android:layout_height="wrap_content" to  android:layout_height="20sp" forcing the items to have a height otherwise they got shrunk to nothingness.

Finally I had to change the background color of my items from null to white because Honeycomb gives the items selected state and that does not paint using the backgroundDrawable I was setting via code. For the first item in the group I was drawing the top left and top right corners rounded. For the final item I was drawing the bottom left and right corners rounded. I know in XML you can set up the normal, selected etc. states but you can not do this in code. For now I have ripped out the rounding of the corners. I am going to try and put that back in tomorrow by bookending the text view group with rounded corner zones. I really liked the way it looked so I hope I can battle it back into place. Not sure why Honeycomb selects the first item in each group but it does. Could be this area would have looked crappy on a phone with a D-Pad too. I already have enough variations of the view in the res directory for my potential item types that doing more sets for each the possible corner types seems a bit overkill.

At least all of the changes I made have left things looking just fine on all the other flavors I test under but I was really surprised I had to make any changes at all. I thought 3.0 would run just like 2.x but with extra features. I will say the preview mode in Eclipse has a setting for 3.0 and it showed the layout being ugly like it is on the device. I also ran the rather slow 3.0 emulator and it matched the device too. At least you can fix things without having access to the physical hardware.

I also find it kind of annoying that the iPad got a ton of press when it sold out quickly but you did not see the same press on the Xoom. Apple is a master and getting their name in the press. Android Tablet is not a thing like the iPad but a general name for tablets from various folks such as Motorola, Samsung, LG just to name a few. Guess it is harder to get press when that is the case. I reserver judgement on the Xoom until I have had a chance to use it more. It still appears to be a flawed device that is an update or two away from being very usable. Google appears to have pulled off their standard Beta release that may stay Beta for a year or may whip into shape with releases just weeks apart. I really hope they push updates to the Xoom quickly as it seems to be vanilla Honeycomb.

One thing I feel both tablet OS versions are missing is multiple user login. I know we use it at home on our various Windows boxes and I use it on my Macbook. I really think people will share tablet devices in the family and they need to step up and allow you to have individual background, web browser and email address settings. I don't need a "switch user" as much as I want a "log user out / log in as new user" functionality. Since Google decided to do a Tablet version of the OS they really should be the first to implement this. Apple seems to lean toward one iOS version for iPhone, iTouch and iPad which will make it a bit harder to pull this off.

No comments:

Post a Comment