Another one of the great issues brought up by a user of JustChess, my simple chess playing Android app, was the fact that when the screen was rotated, you can’t see the bottom half of the board!

Realistically, this would require one of two things:

  1. Fixed portrait mode, not allowing the user to rotate the screen.
  2. Having a separate layout that was appropriate for the rotated screen.

But instead I chose option number 3: Add a scroll view!

Option 1 would limit users from being able to hold their phone a different way if it was more comfortable, and that doesn’t solve any problems, it just limits use.

Option 2 is the proper way to fix this, but I’m done working on this app right now, and involved in other project. This would be a bit of an overhaul, and would take me a considerable amount of time.

Option 3, is cheating. I am adding a scroll view so that the user who wants to play in landscape view can scroll the board to recenter it on the screen. This is fine for hi-res screens we see today, but may be a problem on an older phone, where the user would have to scroll the board back and forth to see all of it.

slide

Either way, you can see the full commit on my GitLab, but here is the pertinent part of the code, in the layout xml file:

<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <LinearLayout
...... edited for space .......
    </LinearLayout>
</ScrollView>

This neatly wraps everything up into a nested scroll view which the user can move by swiping. This may also help if in portrait mode on an older phone with a very small screen.

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *