0

Ich soll eine ScrollView hinzufügen, um Benutzer nach der Schaltfläche nach unten scrollen zu lassen. Es zeigt jedoch nicht, was es zeigen soll.ScrollView zeigt nur eine einzelne Ansicht innerhalb ihrer Unterhierarchie an

Was auch immer ich nach der Button hinzufügen, wird nicht auf dem Gerät/Emulator angezeigt. Ich soll ImageView unter dem Button hinzufügen, aber es scheint nichts nach dem Button anzuzeigen.

Es folgt mein XML:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
     android:weightSum="1"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Description:" 
      android:id="@+id/textView14" 
      android:paddingTop="20dp" 
      android:layout_below="@+id/editText" 
      android:layout_alignLeft="@+id/editText" 
      android:layout_alignStart="@+id/editText" /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Restaurant Location:" 
      android:id="@+id/textView15" 
      android:paddingTop="20dp" 
      android:layout_below="@+id/editText2" 
      android:layout_alignLeft="@+id/editText2" 
      android:layout_alignStart="@+id/editText2" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button2" 
      android:layout_below="@+id/imageView3" 
      android:layout_centerHorizontal="true" />  
    </RelativeLayout> 
</ScrollView> 
+0

Mit „es ist nicht zu zeigen, was sie zeigen sollte“, meinst du nichts Shows oben? – Sufian

+0

Nach der Schaltfläche erscheint nichts, ich nehme an, dass imageView unter der Schaltfläche erscheint, aber es scheint nichts anzuzeigen – ikon

Antwort

1

Das Problem ist, dass Sie nicht die Ansichten korrekt ausrichten. Zum Beispiel gibt es keine editText2, editText und imageView3 und Sie richten Ihre Ansichten nach links oder darunter aus.

Entweder ersetzen RelativeLayout mit LinearLayout oder diese XML verwenden (ich habe diese unbekannte IDs mit dem richtigen ersetzt):

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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <TextView 
      android:id="@+id/textView14" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Description:" 
      android:paddingTop="20dp" /> 
     <TextView 
      android:id="@+id/textView15" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Restaurant Location:" 
      android:paddingTop="20dp" 
      android:layout_below="@+id/textView14" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:layout_below="@id/textView15" 
      android:layout_centerHorizontal="true" /> 
    </RelativeLayout> 
</ScrollView>