2013-07-25 44 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> 
相關問題