如何让我的屏幕上滚动的Andr​​oid的Eclipse中 [英] How Do I Make my Screen Scrollable in Android Eclipse

查看:111
本文介绍了如何让我的屏幕上滚动的Andr​​oid的Eclipse中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在 XML code我之前,我试图调整它是滚动的:

This is the XML code I have before I attempt to adjust it to be scrollable:

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

        <!-- all my widgets -->

</RelativeLayout>

如何修改这使其滚动?拖动一个滚动型从窗口小部件列表只是弄乱一切。

How do I edit this to make it scrollable? Dragging on a ScrollView from the widget list just messes everything up.

推荐答案

请确保你离开版本/编码线在你的文件的顶部。

Make sure you leave the version/encoding line at the very top of your file.

修改 RelativeLayout的滚动型再嵌套一个 RelativeLayout的部分(包含所有窗口小部件)内新滚动型

Change RelativeLayout to ScrollView and then nest a RelativeLayout section (containing all of your widgets) inside that new ScrollView.

请确保你给的 RelativeLayout的某些方面,这应该是一样的滚动型宽度的尺寸。

Make sure you give the RelativeLayout some dimensions, which should be the same as the ScrollView width and height dimensions.

这样做的原因嵌套的 RelativeLayout的包含所有的部件是一个滚动型元素只能有一个子元素(在此情况下,在 RelativeLayout的,而后者则具有其自己的孩子)。

The reason for this nesting of the RelativeLayout that contains all the widgets is that a ScrollView element can only have one child element (in this case, the RelativeLayout, which then has its own children).

因此​​,该code:

Therefore this code:

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

    <!-- all your widgets -->

</RelativeLayout>

打开这个code:

Turns into this code:

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >      

        <!-- all your widgets -->

    </RelativeLayout>

</ScrollView>

这篇关于如何让我的屏幕上滚动的Andr​​oid的Eclipse中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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