# Fixing the size?

My app isn't compatible with all screen sizes. When testing on a small size, my textview overlaps with my button. So, as suggested on the Android Documentation, and many stack overflow pages, I created a new Android Resource Directory:

In my layout-small, I copy and pasted one of the xml layouts of a layout that was overlapping in small screen size. So now, it looks like this:

My layout, activity_finished_before_timer.xml, was just copied from the regular layout to the small layout. Now, in my manifest, I specified the following. I don't know if this is necessary, but after spending hours online searching for the answer, I added it just in case:

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />


After doing everything I could find for hours and hours, the layout is still overlapping. By overlapping, I mean that my textview is under my button on a small screen. It looks fine on a regular screen though.

I have got some advice to do something where I create a layout resource file, but instead of titling the resource file as layout-small, I should title it with the dp size at which my app stops working:

layout-swp365dp

This would mean (In coding terms:)

if (screen size > 365dp) use default;


Now, how do I get the screen size then? On my emulator, the size is given like this:

How do I get the size in dp then? For this method, I would just need to hit and try different screen sizes until I find the one that doesn't work. How do I do that? Is there an easier way?

So, now I am lost I would really appreciate any feedback on how to resolve this issue of why the layout is still being overlapped. It is very odd, since I have done everything I needed to according to all of the sources I looked at. Please help me in figuring out how to make my layout flexible enough for multiple screen sizes. Although I am frustrated at this issue, I am more eager to learn out of it, as it is my first android game.

• Show your xml layout file. I am pretty sure you messed it up... – ElDuderino Sep 12 '16 at 15:22

The smart thing to do would be to create a method, like getScreenRes to get the screen resolution in pixels.

private static int WIDTH = 1280;
private static int HEIGHT = 720;

public static void createDisplay() {

try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); //Use your code, but change these variables!
Display.create(new PixelFormat(), attribs);