滚动型不是在Android平台 [英] ScrollView not working in Android

查看:139
本文介绍了滚动型不是在Android平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

滚动型里面我的布局不工作。这个问题可能是一个愚蠢的。我已经浪费了一个小时吧。

下面是我的XML布局:

 <?XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =1100dp
    机器人:layout_height =1500dp
    机器人:fillViewport =真
    机器人:背景=#f7f7f7
    机器人:layout_weight =1
    机器人:方向=垂直
    机器人:填充=25dp><的LinearLayout
    机器人:ID =@ + ID /容器
    机器人:layout_width =1100dp
    机器人:layout_height =FILL_PARENT
    机器人:方向=垂直>    <的TextView
        机器人:ID =@ + ID / account_heading
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp
        机器人:layout_marginLeft =10dp
        机器人:文字=ACCOUNT
        机器人:文字颜色=#f44b3b
        机器人:TEXTSIZE =18dp/>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =2DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#f44b3b>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT>        <的TextView
            机器人:ID =@ + ID / textView1
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:文字=电子邮件
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <的EditText
            机器人:ID =@ +帐号/电邮
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =300dp
            机器人:layout_toRightOf =@ + ID / textView1
            机器人:EMS =10
            安卓的inputType =textEmailAddress>
        < /&的EditText GT;
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT>        <的TextView
            机器人:ID =@ + ID / change_password
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:文本=更改密码
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <的EditText
            机器人:ID =@ + ID / change_password_et
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =170dp
            机器人:layout_toRightOf =@ + ID / change_password
            机器人:EMS =10
            安卓的inputType =TEXT>
        < /&的EditText GT;
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT>        <的TextView
            机器人:ID =@ + ID /脸谱
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:文字=脸谱
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <的EditText
            机器人:ID =@ + ID / facebook_et
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =255dp
            机器人:layout_toRightOf =@ + ID /脸谱
            机器人:EMS =10
            安卓的inputType =TEXT>
        < /&的EditText GT;
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT>        <的TextView
            机器人:ID =@ + ID /叽叽喳喳
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:文字=推特
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <的EditText
            机器人:ID =@ + ID / twitter_et
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =280dp
            机器人:layout_toRightOf =@ + ID /叽叽喳喳
            机器人:EMS =10
            安卓的inputType =TEXT>
        < /&的EditText GT;
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    <的TextView
        机器人:ID =@ + ID / profile_heading
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp
        机器人:layout_marginLeft =10dp
        机器人:layout_marginTop =10dp
        机器人:文字=标题
        机器人:文字颜色=#f44b3b
        机器人:TEXTSIZE =18dp/>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =2DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#f44b3b>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp>        <的TextView
            机器人:ID =@ + ID /性别
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:文字=性别
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <微调
            机器人:ID =@ + ID / gender_spinner
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =280dp
            机器人:layout_toRightOf =@ + ID /性别/>
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp>        <的TextView
            机器人:ID =@ + ID /生日
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:layout_marginRight =170dp
            机器人:文字=生日
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <按钮
            机器人:ID =@ + ID /的setDate
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_toRightOf =@ + ID /生日
            安卓的onClick =showDatePickerDialog
            机器人:文字=选择日期/>        <的EditText
            机器人:ID =@ + ID / birthdayet
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =100dp
            机器人:layout_toRightOf =@ + ID /生日
            机器人:EMS =10
            安卓的inputType =TEXT
            机器人:文字=生日
            机器人:文字颜色=#f44b3b
            机器人:TEXTSIZE =18dp>
        < /&的EditText GT;
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    < RelativeLayout的
        机器人:layout_width =1100dp
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp>        <的TextView
            机器人:ID =@ + ID / ZIP code
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =10dp
            机器人:layout_marginLeft =10dp
            机器人:文字=邮编code
            机器人:文字颜色=#333333
            机器人:TEXTSIZE =22dp/>        <的EditText
            机器人:ID =@ + ID / ZIP
            机器人:layout_width =500dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =270dp
            机器人:layout_toRightOf =@ + ID / ZIP code
            机器人:EMS =10
            安卓的inputType =号>
        < /&的EditText GT;
    < / RelativeLayout的>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =1DP
        机器人:layout_marginBottom =10dp
        机器人:背景=#c6c6c6>
    < / LinearLayout中>    <的TextView
        机器人:ID =@ + ID /标题
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp
        机器人:layout_marginLeft =10dp
        机器人:layout_marginTop =10dp
        机器人:文字=COOL
        机器人:文字颜色=#f44b3b
        机器人:TEXTSIZE =18dp/>    <的LinearLayout
        机器人:layout_width =900dp
        机器人:layout_height =2DP
        机器人:layout_marginBottom =8DP
        机器人:背景=#f44b3b>
    < / LinearLayout中>< / LinearLayout中>< /滚动型>


解决方案

在滚动型物业内替换该

 的android:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT

和也被删除

 的android:layout_weight =1

这工作得很好。由于@TechEnd

ScrollView inside my layout is not working. The question might be a silly one. I already wasted an hour with it.

Here is my XML layout:

 <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="1100dp"
    android:layout_height="1500dp"
    android:fillViewport="true"
    android:background="#f7f7f7"
    android:layout_weight="1"
    android:orientation="vertical"
    android:padding="25dp" >

<LinearLayout
    android:id="@+id/container"
    android:layout_width="1100dp"
    android:layout_height="fill_parent" 
    android:orientation="vertical">

    <TextView
        android:id="@+id/account_heading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:text="ACCOUNT"
        android:textColor="#f44b3b"
        android:textSize="18dp" />

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="2dp"
        android:layout_marginBottom="10dp"
        android:background="#f44b3b" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:text="Email"
            android:textColor="#333333"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/email"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="300dp"
            android:layout_toRightOf="@+id/textView1"
            android:ems="10"
            android:inputType="textEmailAddress" >
        </EditText>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/change_password"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:text="Change Password"
            android:textColor="#333333"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/change_password_et"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="170dp"
            android:layout_toRightOf="@+id/change_password"
            android:ems="10"
            android:inputType="text" >
        </EditText>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/facebook"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:text="Facebook"
            android:textColor="#333333"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/facebook_et"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="255dp"
            android:layout_toRightOf="@+id/facebook"
            android:ems="10"
            android:inputType="text" >
        </EditText>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/twitter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:text="Twitter"
            android:textColor="#333333"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/twitter_et"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="280dp"
            android:layout_toRightOf="@+id/twitter"
            android:ems="10"
            android:inputType="text" >
        </EditText>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <TextView
        android:id="@+id/profile_heading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:text="Heading"
        android:textColor="#f44b3b"
        android:textSize="18dp" />

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="2dp"
        android:layout_marginBottom="10dp"
        android:background="#f44b3b" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp" >

        <TextView
            android:id="@+id/Gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:text="Gender"
            android:textColor="#333333"
            android:textSize="22dp" />

        <Spinner
            android:id="@+id/gender_spinner"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="280dp"
            android:layout_toRightOf="@+id/Gender" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp" >

        <TextView
            android:id="@+id/Birthday"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="170dp"
            android:text="Birthday"
            android:textColor="#333333"
            android:textSize="22dp" />

        <Button
            android:id="@+id/setDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/Birthday"
            android:onClick="showDatePickerDialog"
            android:text="Pick date" />

        <EditText
            android:id="@+id/birthdayet"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="100dp"
            android:layout_toRightOf="@+id/Birthday"
            android:ems="10"
            android:inputType="text"
            android:text="Birthday"
            android:textColor="#f44b3b"
            android:textSize="18dp" >
        </EditText>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <RelativeLayout
        android:layout_width="1100dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp" >

        <TextView
            android:id="@+id/zipcode"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:text="Zip Code"
            android:textColor="#333333"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/zip"
            android:layout_width="500dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="270dp"
            android:layout_toRightOf="@+id/zipcode"
            android:ems="10"
            android:inputType="number" >
        </EditText>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="1dp"
        android:layout_marginBottom="10dp"
        android:background="#c6c6c6" >
    </LinearLayout>

    <TextView
        android:id="@+id/heading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:text="COOL"
        android:textColor="#f44b3b"
        android:textSize="18dp" />

    <LinearLayout
        android:layout_width="900dp"
        android:layout_height="2dp"
        android:layout_marginBottom="8dp"
        android:background="#f44b3b" >
    </LinearLayout>      

</LinearLayout>

</ScrollView>

解决方案

Replaced this inside the ScrollView property

android:layout_width="fill_parent"
android:layout_height="fill_parent"

and also removed

android:layout_weight ="1"

This worked fine. Thanks to @TechEnd

这篇关于滚动型不是在Android平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆