Android的滚动型不滚动 [英] Android ScrollView not scrolling

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

问题描述

我已经解决了我的问题。我选择代替有一个头,并且总是在屏幕的底部和顶部分别位于页脚。然后,我创建了一个中心内容,我包围的滚动型布局中。我已经更新了code以下,如果人们有兴趣看到的现在的样子。

 <?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:可聚焦=真
    机器人:focusableInTouchMode =真
    机器人:背景=#FFFFFF>    <的LinearLayout机器人:ID =@ + ID /头
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:背景=@布局/头
        机器人:layout_alignParentTop =真正的>
        < ImageView的机器人:SRC =@绘制/标志
            机器人:contentDescription =@字符串/ logo_description
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:填充=10dip/>
    < / LinearLayout中>    <滚动型机器人:方向=垂直
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =350dip
        机器人:layout_below =@ ID /头>
        <的LinearLayout机器人:方向=垂直
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:填充=20dip>
            <! - 电子邮件标签 - >
            <的TextView的android:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字颜色=#372C24
                机器人:文字=@字符串/邮件/>
            < EditText上机器人:ID =@ + ID / email_field
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =5dip
                机器人:单线=真
                安卓的inputType =textEmailAddress/>
            <! - 密码标签 - >
            <的TextView的android:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =10dip
                机器人:文字颜色=#372C24
                机器人:文字=@字符串/密码/>
            < EditText上机器人:ID =@ + ID / password_field
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:单线=真
                安卓的inputType =textPassword/>
            <! - 登录按钮 - >
            <按钮机器人:ID =@ + ID / login_button
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =25dip
                机器人:文字=@字符串/登陆/>
            <! - 注册按钮 - >
            <按钮机器人:ID =@ + ID / register_button
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =25dip
                机器人:文字=@字符串/ register_button/>
        < / LinearLayout中>
    < /滚动型>    <的LinearLayout机器人:ID =@ + ID /页脚
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =90dip
        机器人:背景=@布局/页脚
        机器人:layout_alignParentBottom =真正的>
    < / LinearLayout中>< / RelativeLayout的>


解决方案

我删除了这条线从AndroidManifest.xml文件

安卓主题=@安卓风格/ Theme.NoTitleBar.Fullscreen

和加入这一行

安卓主题=@安卓风格/ Theme.NoTitleBar

它既有固定我的滚动的应用程序,使我的应用程序看起来更加悦目。但是,我不知道这是否是正确的修复。

I have solved my question. I chose to instead have a header and a footer that are always located at the bottom and top of the screen respectively. Then I created a "center content" which I enclosed within a ScrollView layout. I have updated the code below if people are interested in seeing what it now looks like.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:background="#FFFFFF">

    <LinearLayout android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@layout/header"
        android:layout_alignParentTop="true">
        <ImageView android:src="@drawable/logo"
            android:contentDescription="@string/logo_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dip"/>
    </LinearLayout>

    <ScrollView android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="350dip"
        android:layout_below="@id/header">
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="20dip" >
            <!--  Email Label -->
            <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372C24"
                android:text="@string/email"/>
            <EditText android:id="@+id/email_field"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:inputType="textEmailAddress"/>
            <!--  Password Label -->
            <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:textColor="#372C24"
                android:text="@string/password"/>
            <EditText android:id="@+id/password_field"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:inputType="textPassword"/>
            <!-- Login button -->
            <Button android:id="@+id/login_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dip"
                android:text="@string/login"/>
            <!-- Register button -->
            <Button android:id="@+id/register_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dip"
                android:text="@string/register_button"/>
        </LinearLayout>
    </ScrollView>

    <LinearLayout android:id="@+id/footer"
        android:layout_width="fill_parent"
        android:layout_height="90dip"
        android:background="@layout/footer"
        android:layout_alignParentBottom="true">
    </LinearLayout>

</RelativeLayout>

解决方案

I removed this line from the AndroidManifest.xml file

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

and added this line

android:theme="@android:style/Theme.NoTitleBar"

it has both fixed my scrolling app and made my app look more visually appealing. However, I am not sure if this is the correct fix.

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

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