-1

J'ai une mise en page, avec une image, un bouton et une textview. Lorsque je définis l'image comme arrière-plan, cette image d'arrière-plan est seulement la moitié de l'écran, et le reste est noir. Cette méthode est bonne sur une autre mise en page où j'ai beaucoup de choses, mais ici, c'est seulement sur la moitié de l'écran. Comment puis-je faire ce droit?Image de fond d'une mise en page n'est pas acroos écran, mais seulement la moitié?

Ma mise en page:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView01" 
    android:layout_height="wrap_content" android:layout_width="fill_parent"> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:background="@drawable/background" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
<ImageView 
    android:layout_width="fill_parent" 
    android:src="@drawable/bonbon" 
    android:id="@+id/imageView1" 
    android:layout_height="wrap_content"/> 
<cro.perger.bonbon.MyTextView 
    android:id="@+id/textView1" 
    android:text="Stanje aktiviranih paketa" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content"/> 
<Button android:layout_height="wrap_content" 
    android:text="Provjeri stanje" 
    android:id="@+id/provjeriStanje" 
    android:layout_width="fill_parent"/> 
<TextView android:text=" " 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 
</LinearLayout> 
</ScrollView> 
+0

au lieu d'Android: src = "@ drawable/Bonbon" essayer android: background = "@ drawable/Bonbon" –

+0

non, Bonbon est seule image, pas le fond ..... – Goran

Répondre

1

Vous avez une ScrollView en tant que composant racine, il a sa hauteur définie comme "wrap_content". C'est, très probablement, la cause de votre problème. Essayez cette version:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView01" 
    android:background="@drawable/background" 
    android:layout_height="fill_parent" android:layout_width="fill_parent"> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"   
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
<ImageView 
    android:layout_width="fill_parent" 
    android:src="@drawable/bonbon" 
    android:id="@+id/imageView1" 
    android:layout_height="wrap_content"/> 
<cro.perger.bonbon.MyTextView 
    android:id="@+id/textView1" 
    android:text="Stanje aktiviranih paketa" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content"/> 
<Button android:layout_height="wrap_content" 
    android:text="Provjeri stanje" 
    android:id="@+id/provjeriStanje" 
    android:layout_width="fill_parent"/> 
<TextView android:text=" " 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 
</LinearLayout> 
</ScrollView> 
+0

Remerciez toi. Cela fonctionne parfaitement :) – Goran

0

Votre scrollview est enroulant le contenu qui est probablement pas remplir tout l'écran.

Modifier android: layout_height = "wrap_content" à fill_parent dans la balise scrollview.

0

Maintenant, essayez ceci ...

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView01" android:background="@drawable/Path" 
    android:layout_height="fill_parent" android:layout_width="fill_parent"> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <ImageView android:layout_width="fill_parent" android:src="@drawable/Path" 
      android:id="@+id/imageView1" android:layout_height="wrap_content" /> 

     <Button android:layout_height="wrap_content" android:text="Provjeri stanje" 
      android:id="@+id/provjeriStanje" android:layout_width="fill_parent" /> 
     <TextView android:text=" " android:textAppearance="?android:attr/textAppearanceLarge" 
      android:id="@+id/textView2" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 
</ScrollView> 
Questions connexes