Search code examples
androidandroid-layoutscreenoverlapnexus-5

Overlap background (and overlap image) on Nexus 5


This is the Overlap Background (or Overlap Image) problem which I only get it on Nexus 5 Emulator while testing. I have not tested on Nexus 5 Device, but I think the Emulator should show quite correct.

Overlap Background or Overlap  Image

This is my coding indicated how to support multiple screen, it works for the others device, not for Nexus 5 emulator. Followed the answer in here also but it not works.

In my application, I used Fragment to transfer among pages. It happened when I transfer from first page (red words in image) to second page (blue words in image). Background of second page is Black, but it still so Background of first page, it's so strange.

In /res folder, I used :

  • Medium quality image in /drawable-hdpi.

  • High quality image in /drawable-xhdpi.

  • Higher quality image in /drawable-xxhdpi.

  • Also tried with different layout folder, but it not works for me : copy all files from /layout folder to /layout-xhdpi or /layout-xxhdpi.

In my manifest.xml file : (Although defined screenDensity=445 since Nexus 5 has screen density is 445 ppi, it still not works)

<compatible-screens>

    <!-- all small size screens -->
    <screen
        android:screenDensity="ldpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="445"
        android:screenSize="small" />
    <screen
        android:screenDensity="480"
        android:screenSize="small" />

    <!-- all normal size screens -->
    <screen
        android:screenDensity="ldpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="normal" />
    <!-- Nexus 5 : 445ppi -->
    <screen
        android:screenDensity="445"
        android:screenSize="normal" />
    <screen
        android:screenDensity="480"
        android:screenSize="normal" />
    <!-- all large size screens -->

    <screen
        android:screenDensity="ldpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="445"
        android:screenSize="large" />
    <screen
        android:screenDensity="480"
        android:screenSize="large" />
    <!-- all x large size screens -->

    <screen
        android:screenDensity="ldpi"
        android:screenSize="xlarge" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="xlarge" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="xlarge" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="xlarge" />
    <screen
        android:screenDensity="445"
        android:screenSize="xlarge" />
    <screen
        android:screenDensity="480"
        android:screenSize="xlarge" />
</compatible-screens>

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

Who know this problem, please tell me, Thanks so much.

p/s : Followed screens_support but not works also.


Solution

  • In all your xml files, should define the background color for it, it will solve the problem :

    Add this android:background="@android:color/black" in to the View tag you defined.

    p/s : This problem happened from you use Fragment in the project.

    p/s : This case only avoid Background was overlapped.