How to set up portrait mode on Android Things

Before we start the topic, you should know by now that Android and Android Things are two different operating systems.

The significant difference is that Android is open-source and Android Things isn’t. Thus, you have no control over Android Things.

Back to the topic.

Recently we found a sluggish portrait mode issue with android things. When you set your app to portrait mode, the app will become sluggish. We were not able to find any solution to this issue on the internet, and Google hasn’t responded to our issued ticket yet. However, we did find that other people are also facing the same issue.

The issue is that with Google’s android things OS. Whenever you use


It works properly on your emulator but it will become very slow when you install the app on Raspberry Pi.

As mentioned earlier someone found out about this problem before us.

We found @jaythecelt is having the same issue with different hardware which is the TechNexion PICO-PI-IMX7.

We also found he has issued a ticket to google

In this issue tracker, @jaythecelt mentioned

“This app has set screenOrientation=’portrait’ on its activities. I found out that not only app displayed in portrait has slow responses, but every other app has”

I agree with him.

At the end of the ticked, it marked as fixed.

However, we found its problem remains unfixed on Raspberry Pi 3 B.

After several hours of research and experiment. I found out if I modify the config file on Raspberry Pi. I can display my app in portrait mode and in the app, android:screenOrientation=”landscape” remains unchanged.

Here is the code you need to change for the config file.

Step 1

Rotate the screen.


In this case, when display_rotate=3, it means you rotate the screen 270 degrees. You can also make it equal to 1 or 2, which means 90 and 180 degrees.

At this point, the display is rotated but you will have an issue with the screen.
Display problem after config rotation

As you can see the image jumps up and down.

In the beginning, I didn’t know what’s causing this issue then after consulting with my father who is a geophysicist and a very smart person. He told me this could be caused by frame buffer settings.

So I looked into it, on raspberry pi documentation. There is a part of the framebuffer.

Read everything on this page in case your screen size is not the same as ours. Then we can go to the next step.

Step 2

Add these code in your config file, you might need to adjust the number if your screen aspect is not 9:16



I know the number might not make sense, but I tried it, and it works. Some developers didn’t pay attention to the difference between height and width.

Step 3

Last step if you want to make your pi run faster and perform better. You can reassign the memory and overclock the pi.

To reassign memory to GPU add this code, the number can be adjusted.


To overclock the pi by 20% add these code.


Also, if you are going to use these codes in step 3, make sure you cool your pi by add heatsinks and a small fan to it. Otherwise, restarts will be triggered whenever your pi is overheated.


However, this is only a temporary solution. The thing is whenever you pushed an update for your app, the config file will be reset, and there’s nothing you can do to keep the config file. But if you don’t need to update your app. This solution should be fine.