在滚动视图没有滚动 [英] No scrolling in scrollview

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

问题描述

我有一个问题,我的滚动视图...

i have a problem with my scrollview...

我的XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content">

         <ScrollView android:id="@+id/scrollView1" android:layout_width="wrap_content" android:layout_height="match_parent">
             <RelativeLayout [...]>
                 <TextView [...]></TextView>
                 <Spinner [...]></Spinner>
                 <Button [...]></Button>
                 <ImageButton [...]></ImageButton>
                 <TextView [...]></TextView>
                 <TableLayout [...]>
                     <TableRow [...]>
                         <TextView [...]></TextView>
                         <TextView [...]></TextView>
                         <TextView [...]></TextView>
                     </TableRow>
                     <TableRow [...]>
                         <AutoCompleteTextView [...]></AutoCompleteTextView>
                         <AutoCompleteTextView [...]></AutoCompleteTextView>
                         <Spinner [...]></Spinner>
                     </TableRow>
                 </TableLayout>
            </RelativeLayout>
         </ScrollView>
</LinearLayout>

当我尝试在我的应用程序滚动它不会工作...我做了什么错?
我删除从元素的属性。如果你需要他们来解决这个问题,我可以添加它们。
我这样做是为了获得更好的概述。

When i try to scroll in my App it wont work... what did i do wrong? i deleted the properties from the elements. if you need them to solve the problem i can add them. i did it to get a better overview.

谢谢,
preXX

thanks, prexx

推荐答案

尝试添加滚动型父。 SWICH地方与LinearLayout中。
不要忘记,以增加您的滚动型,而不是的LinearLayout以下内容:

Try adding the ScrollView as the parent. Swich place with LinearLayout. And dont forget to add the following on your ScrollView instead of the LinearLayout:

xmlns:android="http://schemas.android.com/apk/res/android"

和所述滚动型的layout_widht和layout_height应设置为FILL_PARENT

And layout_widht and layout_height of the ScrollView should be set to "fill_parent"

这是我的code,它使用滚动型日历中我做了,可以帮助你:

This is my code which uses ScrollView in a calendar I made, could help you:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg">
<LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Button android:id="@+id/dayView" android:text="Day" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/>
    <Button android:id="@+id/weekView" android:text="Week" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/>
    <Button android:text="Month" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:enabled="false"/>
    <Button android:id="@+id/eventsView" android:text="Events" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/prevMonth"
        android:src="@drawable/calendar_left_arrow_selector"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </ImageView>
    <Button
        android:id="@+id/currentMonth"
        android:layout_weight="0.6"
        android:textColor="#FFFFFF"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:background="@drawable/calendar_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </Button>
    <ImageView
        android:id="@+id/nextMonth"
        android:src="@drawable/calendar_right_arrow_selector"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </ImageView>
</LinearLayout>
<LinearLayout
    android:layout_gravity="center"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView android:layout_width="wrap_content" android:layout_height="20dp" android:text="Week" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/monday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/tuesday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/wednesday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/thursday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/friday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/saturday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/>
    <TextView android:id="@+id/sunday" android:layout_width="wrap_content" android:layout_height="20dp" android:text="" android:textColor="#000000" android:layout_weight="1"/> 
</LinearLayout>
<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_weight="1">
    <ViewFlipper
       android:id="@+id/flipper"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal">
        <GridView
            android:id="@+id/weeks"
            android:numColumns="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="8"
            android:scrollbars="none">
        </GridView>
        <GridView
            android:id="@+id/calendar"
            android:numColumns="7"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:scrollbars="none">
        </GridView>
    </LinearLayout>
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal">
        <GridView
            android:id="@+id/weeks2"
            android:numColumns="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="8"
            android:scrollbars="none">
        </GridView>
        <GridView
            android:id="@+id/calendar2"
            android:numColumns="7"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:scrollbars="none">
        </GridView>
    </LinearLayout>
</ViewFlipper>
</LinearLayout>
<LinearLayout
        android:id="@+id/bottom_layout" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/create_event"
            android:text="Create event"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

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

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