0

i got a very weird type of problem while developing a basic android app. While I've created an app in which the background image of an app is visible to all the devices except nexus devices of android marshmallow. Kindly help me in solving the error. Below is the code and screenshot attached.

https://i.stack.imgur.com/OGs1z.png

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/abst"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="project.scytech.mi_agenda.LoginActivity">

    <include
        android:id="@+id/linearLayout"
        layout="@layout/appname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/loginLayout"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" />

    <LinearLayout
        android:id="@+id/loginLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical"
        android:paddingTop="16dp">

        <EditText
            android:id="@+id/editTextDomainName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/domainName"
            android:inputType="textUri"
            android:textColorHint="#FFF8E5" />

        <EditText
            android:id="@+id/editTextUsername"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/username"
            android:textColorHint="#FFF8E5" />

        <EditText
            android:id="@+id/editTextPassword"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:fontFamily="@string/username"
            android:hint="@string/password"
            android:inputType="textPassword"
            android:textColorHint="#FFF8E5" />

        <Button
            android:id="@+id/buttonLogin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center"
            android:layout_marginTop="16dp"
            android:clickable="true"
            android:onClick="loginClicked"
            android:text="@string/login" />
    </LinearLayout>


</RelativeLayout>
Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
Vipul K. Patil
  • 128
  • 1
  • 10

1 Answers1

0

Please try to use an ImageView and set it as background.

It means:

Use a RelativeLayout or a FrameLayout and define your ImageView as the first child. The first objects defined are the lowest in the z-order (i.e. they will be "below" the other views).

From: Setting an ImageView to the background Android

To fit it to whole screen device use match_parent or android:scaleType="fitXY"

Your code should look like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#000000" >

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="42dp"
    tools:ignore="ContentDescription" />

//Rest of widgets......

Check also: How to make image fill RelativeLayout background without stretching

It should work

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94