2013-07-25 46 views
-1

这是XML代码我之前,我尝试调整它是滚动:如何让我的屏幕滚动Android中的Eclipse

<?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> 

如何编辑这使它滚动?从窗口小部件列表中拖拽ScrollView只会将所有东西混淆。

+0

我不是downvoting .. – Aravin

+0

@ 753它看起来并不像你对我已经接受任何答案 –

回答

4

请确保您将version/encoding行保留在文件最顶端。

RelativeLayout更改为ScrollView,然后在该新的ScrollView中嵌套RelativeLayout部分(包含所有小部件)。

确保你给RelativeLayout某些方面,这应该是一样的ScrollView宽度高度尺寸。

嵌套RelativeLayout包含所有小部件的原因是ScrollView元素只能有一个子元素(在这种情况下,RelativeLayout,然后它有自己的孩子)。

因此,该代码:

<?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> 

打开这个代码:

<?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> 
相关问题