0
因此,我將RelativeLayout與ScrollView包圍起來,但是當我在Android模擬器中運行它時,它仍然不滾動。我是否意外搞亂了一些代碼?因爲它只是停止滾動。似乎無法讓ScrollView正常工作
這裏是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
android:id="@+id/new_meal_form_relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/meal_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:text="@string/meal_label"
android:textSize="20sp"/>
<EditText
android:id="@+id/meal_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/meal_label"
android:hint="Event Title"
android:inputType="textCapSentences"
android:maxLines="1"/>
<EditText
android:id="@+id/meal_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/meal_name"
android:hint="Location(eg: CSC Room232)* "
android:inputType="textCapSentences"
android:maxLines="1"/>
<EditText
android:id="@+id/meal_event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/meal_location"
android:gravity="top"
android:hint="Description of the event. What kind of food. Any additional info... \n"
android:inputType="textMultiLine|textCapSentences"/>
<TextView
android:id="@+id/textViewRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/meal_event"
android:text="Rating: "/>
<Spinner
android:id="@+id/rating_spinner"
android:layout_width="71dp"
android:layout_height="47dp"
android:layout_alignTop="@+id/textViewRequired"
android:layout_toRightOf="@+id/textViewRating"/>
<TextView
android:id="@+id/textViewRequired"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textViewRating"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:text="*Required"
android:textColor="#ffff4b48"
android:textSize="15sp"/>
<com.parse.ParseImageView
android:id="@+id/meal_preview_image"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_below="@+id/rating_spinner"
android:layout_centerHorizontal="true"/>
<ImageButton
android:id="@+id/photo_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_photo"
android:layout_below="@+id/meal_preview_image"
/>
<Button
android:id="@+id/save_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/photo_button"
android:layout_toLeftOf="@+id/cancel_button"
android:background="#ffff001f"
android:text="@string/save_button_text"/>
<Button
android:id="@+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/photo_button"
android:text="@string/cancel_button_text"/>
</RelativeLayout>
</ScrollView>
我試過了,它沒有工作。還有爲什麼「wrap_content」? – mannermakethman