1

I have set ImageView as background for my Activity layout like this

<?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">

    <ImageView
        android:id="@+id/backgroundImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/default_bg_welcome"
        tools:ignore="ContentDescription"/>

     <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

      <!-- My content -->

    </RelativeLayout>

</RelativeLayout>

Works great for API <23, but somehow on Android 6.0, the background shows as white. Removed any theme for the activity in Manifest, still the same. Has anybody had this issue? Any ideas what might have gone wrong?

Joks222
  • 13
  • 3

2 Answers2

0

I tried with API 23 and that works well for me...later on it depends on your image

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">

     <ImageView
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:background="@drawable/male"
                    android:id="@+id/list_item_giftsharealert_propic"
                    />
     </LinearLayout>

or else you can set this line in your parent layout

android:background="@drawable/male"
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
  • Thanx. The problem was in my image, yes. Somehow just it did not show on Android 6.0. Probably it was too large. Thanx a lot for everybody, stupid mistake, that did not test another image. – Joks222 Oct 21 '15 at 10:29
0

Try set Background in layout like:

<?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:background="@drawable/yourbackground"
 android:layout_height="match_parent">

<ImageView
    android:id="@+id/backgroundImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:src="@drawable/default_bg_welcome"
    tools:ignore="ContentDescription"/>

 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

  <!-- My content -->

</RelativeLayout>

AndroidLTG
  • 91
  • 1
  • 11