Detect if the phone is old / NEXUS4 to avoid display issues

31 Views Asked by At

It looks like some issues appears on the display of my app when I run it on old devices. Here is what I observe.

1) When I open my app in recent phones (above NEXUS 5) the screen of the dialog I am showing appear properly all the elements are there. They are all defined with a height of "WRAP_CONTENT".

2) When I run my app in NEXUS 4, the dialog appears cut, even though there is still space on the screen...For whatever reason it looks like the "WRAP_CONTENT" does not work... but if I set the height of the dialog programmaticaly then it is working (I try setup the height of the button and the framelayout without success).

Any idea what I am missing there? If you advise me to set the height programmaticaly, then my problems become how to know if the user is using an old device or not so that when he is I define the pop-up taking the whole screen otherwise not...

I have included a screenshot of what I see on recent phone (just below, you can see the button cool completely) and what I see on NEXUS4 (second screenshot you can only see the beginning of the button cool...)

what I have on recent phone What I see on NEXUS 4

and below is the XML I am using

  <?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/popup_swiperewards_flMainwindow"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_margin="32dp"
        android:id="@+id/popup_swiperewards_llMaincontainer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:background="#DD000000">

        <TextView
            android:id="@+id/popup_swiperewards_tvUsername"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="USER NAME"
            android:textColor="@android:color/white"
            android:textStyle="bold" />

        <ImageView
            android:id="@+id/popup_swiperewards_ivSeparator1"
            android:scaleType="fitXY"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/stripe_separator" />

        <pro.appus.takemeout.ui.views.ViewPagerWrapContent
            android:id="@+id/popup_swiperewards_vpAwardcontainer"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <com.viewpagerindicator.CirclePageIndicator
            android:id="@+id/popup_swiperewards_cpiCircleindicator"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            app:fillColor="#FFFFFF"
            app:pageColor="@android:color/transparent"
            app:radius="6dp"
            app:strokeColor="#FFFFFF"
            app:strokeWidth="1dp" />

        <ImageView
            android:id="@+id/popup_swiperewards_ivSeparator2"
            android:scaleType="fitXY"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/stripe_separator" />

        <TextView
            android:id="@+id/popup_swiperewards_tvComeagain"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Come again tomorrow \n to collect %d TMO"
            android:textAllCaps="true"
            android:textColor="@android:color/white"
            android:textStyle="bold" />

        <FrameLayout
            android:id="@+id/popup_swiperewards_btnCoolContainer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <Button
                android:id="@+id/popup_swiperewards_btnCool"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:includeFontPadding="true"
                android:background="@drawable/appsettings_button_silver"
                android:text="Cool"
                android:textAllCaps="true"
                android:textColor="@android:color/white" />
        </FrameLayout>
    </LinearLayout>
</FrameLayout>
1

There are 1 best solutions below

0
Laurent On

I found the mistake, it was in the code there where the margin was too big for that screen...

  <LinearLayout

        **android:layout_margin="32dp"**

        android:id="@+id/popup_swiperewards_llMaincontainer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:background="#DD000000">