滚动未启用

时间:2015-07-17 06:50:07

标签: android scrollview android-scrollview android-scroll

我设计了一个注册屏幕,其中有一个Scroll view,但Scroll view无效。

我无法找到Scroll无法正常工作的原因,请帮我解决这个问题。

以下是参考代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include
        android:id="@+id/tool_bar"
        layout="@layout/tool_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <ImageView
            android:id="@+id/sign_up_profile_image"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="30dp"
            android:background="@drawable/shape_rectangle_rounded_corner"
            android:padding="10dp"
            android:scaleType="fitXY"
            android:src="@drawable/icon_avatar" />


        <RelativeLayout
            android:id="@+id/container_two"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/container_three"
            android:layout_below="@+id/sign_up_profile_image"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="20dp"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/first_last_name_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:weightSum="100">

                <ui.customviews.MaterialEditText
                    android:id="@+id/sign_up_first_name_edit_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="1dp"
                    android:layout_marginTop="2dp"
                    android:layout_weight="50"
                    android:hint="@string/first_name_hint"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName"
                    android:textSize="18sp"
                    app:baseColor="#363636"
                    app:floatingLabel="normal"
                    app:primaryColor="#000000" />

                <customviews.MaterialEditText
                    android:id="@+id/sign_up_last_name_edit_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="1dp"
                    android:layout_marginTop="2dp"
                    android:layout_weight="50"
                    android:hint="@string/last_name_hint"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName"
                    android:textSize="18sp"
                    app:baseColor="#363636"
                    app:floatingLabel="normal"
                    app:primaryColor="#000000" />
            </LinearLayout>

            <ui.customviews.MaterialEditText
                android:id="@+id/sign_up_email_edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/first_last_name_container"
                android:hint="@string/email"
                android:imeOptions="actionNext"
                android:inputType="textEmailAddress"
                android:textSize="18sp"
                app:baseColor="#363636"
                app:floatingLabel="normal"
                app:primaryColor="#000000"

                />

            <ui.customviews.MaterialEditText
                android:id="@+id/sign_up_password_edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/sign_up_email_edit_text"
                android:hint="@string/password"
                android:imeOptions="actionDone"
                android:inputType="textPassword"
                android:textSize="18sp"
                app:baseColor="#363636"
                app:floatingLabel="normal"
                app:primaryColor="#000000" />

        </RelativeLayout>


        <RelativeLayout
            android:id="@+id/container_three"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="@dimen/activity_vertical_margin">


            <TextView
                android:id="@+id/sign_up_terms_text_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:gravity="center_horizontal"
                android:lineSpacingExtra="2dp"
                android:lineSpacingMultiplier="1.2"
                android:text="By signing up, you accept to the Terms and Conditions and Privacy Policy"
                android:textColor="#6b6b6b"
                android:textSize="14sp" />

            <Button
                android:id="@+id/sign_up_accept_button"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_below="@+id/sign_up_terms_text_view"
                android:layout_marginLeft="@dimen/activity_vertical_margin"
                android:layout_marginRight="@dimen/activity_vertical_margin"
                android:background="#025961"
                android:text="@string/accept_and_signup"
                android:textColor="@android:color/white"
                android:textSize="14sp" />
        </RelativeLayout>
    </RelativeLayout>
</ScrollView>

</LinearLayout>

2 个答案:

答案 0 :(得分:0)

解决方案可以将ScrollView更改为:

has_many :authorizations

def self.from_omniauth(auth)
  authorization = Authorization.where(:provider => auth.provider, :uid => auth.uid.to_s).first_or_initialize
  authorization.token = auth.credentials.token
  if authorization.user.blank?
    user = User.where('email = ?', auth["info"]["email"]).first
    if user.blank?
     user = User.new
     user.password = Devise.friendly_token[0,10]
     user.email = auth.info.email
     user.save
    end
   authorization.user_id = user.id       
  end
  authorization.save
  authorization.user
end

然后你应该改变嵌套的布局高度

答案 1 :(得分:0)

尝试像这样,添加内部线性布局,它将滚动到页面结束。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

     <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

// Your xml Code Put Here

        </LinearLayout>
    </ScrollView>
</Relativelayout>