这是在 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>