5
\$\begingroup\$

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:

Directories

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:

enter image description here

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;
else use default-adjusted.

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

enter image description here

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.

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

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);
    Display.setTitle("Aincrad Online ALPHAV.4.1");
    } catch(LWJGLException e) {
        e.printStackTrace();
    }



}

Use the method you created to get the screen resolution to change the WIDTH and HEIGHT variables in the code. Of course, you should translate all the code to the language you are using

\$\endgroup\$
  • \$\begingroup\$ This does not answer the question at all... OP doesn't know how to get screen resolution and saying "create a method for it" without providing the method body is useless. \$\endgroup\$ – Charanor Apr 18 '17 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.