2017-01-12 5 views
0

Ich erstelle eine App, die ScrollViews erfordert, und ich bekomme Probleme mit ihnen. Als ich den Scrollview hinzugefügt habe, wurde das Layout der App nach oben verschoben und ich weiß nicht, was das Problem ist. Wie kann ich dieses Problem loswerden? Der Screenshot von vor und nach dem ich die Scrollview hinzugefügt unter Before Scrollview ist & After Scrollviewwie scrollviews in android verwenden

Sie den Code unten nach Scroll

<RelativeLayout 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/backgroundColor" 
    android:orientation="vertical" 
    android:padding="24dp" 
    tools:context=".activity.MainActivity"> 

    <ImageView 
     android:id="@+id/city_image_view" 
     android:layout_width="72dp" 
     android:layout_height="72dp" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="60dp" 
     android:src="@drawable/ic_place_black_36dp" /> 

    <TextView 
     android:id="@+id/city_text_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/city_image_view" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="16dp" 
     android:fontFamily="sans-serif-medium" 
     android:text="@string/select_city" 
     android:textSize="24sp" /> 

    <Spinner 
     android:id="@+id/city_spinner" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@id/city_text_view" 
     android:layout_alignRight="@id/city_text_view" 
     android:layout_below="@id/city_text_view" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="16dp" 
     android:focusableInTouchMode="true" 
     android:spinnerMode="dropdown" /> 

    <Button 
     android:id="@+id/city_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@id/city_text_view" 
     android:layout_below="@id/city_spinner" 
     android:layout_marginTop="36dp" 
     android:text="@string/send_button" /> 

</RelativeLayout> 

Antwort

0

android:fillViewport="true" Objekt zur Ihrer Ansicht blättern hinzufügen. Es wird Ihnen helfen, perfektes Layout zu bekommen.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    xmlns:tools="http://schemas.android.com/tools"> 
<!--Enter your code here--> 

</ScrollView> 
Verwandte Themen