0
misbehaving

Ich habe eine Aktivität mit diesem Layout:In einem Fragment, wenn ein Bild als Hintergrund eines RelativeLayout in Scrollview gesetzt ist, wird die RelativeLayout

<?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:id="@+id/fragment_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".activities.MainActivity" /> 

Dann dieses Fragment Layout Ich habe, was ich bin in der fragment_container der Aktivität Transaktionen:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scroll_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

    <RelativeLayout 
     android:id="@+id/relative_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bg_login"> 


    </RelativeLayout> 

</ScrollView> 

die ziehbar bg_login ist: bg_login Aber das merkwürdige, was geschieht ist, versteckt sich das Hintergrundbild (bg_login) alle Inhalte in RelativeLayout, im Vorschaufenster sowie als wh de Ich betreibe die App. Ich kann nicht herausfinden, warum das passiert! Bitte helfen Sie.

+0

Versuchen Sie, Hintergrund zur Bildansicht hinzuzufügen und setzen Sie relativ dazu mit Rahmen-Layout – g7pro

Antwort

0

Ich weiß nicht, was Sie tun möchten, möchten Sie mehrere Hintergrund in relativen Layouts beim Scrollen haben oder nicht. Aber ich nehme an, Sie die Scroll-Ansicht, wenn ein Kind Element mit Hintergrund ist nicht Best Practice. So scoll Ansicht muss auf ein Kind von Eltern festgelegt haben einen Hintergrund für gute Praxis. Dies kann Ihnen helfen:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
android:background="@drawable/bg_login"> 
<ScrollView 
    android:id="@+id/scroll_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

    <RelativeLayout 
     android:id="@+id/relative_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 


    </RelativeLayout> 

</ScrollView> 
</RelativeLayout> 
Verwandte Themen