【问题标题】:Scroll is not getting enabled滚动未启用
【发布时间】:2015-07-17 06:50:06
【问题描述】:

我设计了一个注册屏幕,其中有一个 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>

【问题讨论】:

    标签: android scrollview android-scrollview android-scroll


    【解决方案1】:

    试试这样,在Linear layout里面添加,它会一直滚动到页尾。

    <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>
    

    【讨论】:

      【解决方案2】:

      解决办法可以把ScrollView改成:

      <ScrollView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:fillViewport="true"
          >
      

      那么你也应该改变嵌套的布局高度

      【讨论】:

      • 让我试试,是的,你只是改变了身高
      • 那么我认为您还必须更改嵌套布局的高度
      • 是的,我也一样,想重新设计它,但在此之前我想检查一下我是否犯了任何错误
      • 不,它不起作用,所有的布局都被折叠了
      • 尝试为 ScrollView 的嵌套布局分配一个固定的高度...只是尝试...然后您将不得不重新设计它
      猜你喜欢
      • 2015-12-22
      • 1970-01-01
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多