2015-12-10 6 views
-2

Я уже видел много учебников, пытающихся поместить изображение в качестве фона моей основной деятельности. Протестировано много способов, и теперь я с этим:Попытка нарисовать произвольное фоновое изображение

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


<merge 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView" 
     android:src="@drawable/library" 
     android:scaleType = "centerCrop" 
     android:contentDescription="@string/bckgrndimg" /> 

<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="#ffffff" 
    android:orientation="vertical" 
    > 

    <ListView 
     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="370dp" 
     android:layout_marginLeft="0dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentStart="true"> 
    </ListView> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/nuevo_libro" 
     android:id="@+id/nuevoLibro" 
     android:layout_above="@android:id/list" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="42dp" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="@string/biblioteca_virtual" 
     android:id="@+id/textView2" 
     android:layout_above="@+id/nuevoLibro" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="31dp" /> 



</RelativeLayout> 
</merge> 

Хорошо, это должно случиться, не так ли? Мое «библиотечное» изображение - это изображение PNG размером 900x600, но оно просто не отображается на экране.

Я что-то упустил?

Спасибо!

+0

после полного файла макета –

+0

Там у вас есть! – Zerok

+0

изменить ваш Relativelayout layout_height = "wrap_content" –

ответ

2

Вам нужен вид изображения? Вы могли бы сделать что-то вроде этого:

<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/library.." 
    ... 
> 
... 
</RelativeLayout> 
0

Изменить цвет фона RelativeLayout

android:background="#ffffff" 

Для

android:background="@android:color/transparent" 
Смежные вопросы