2012-07-27 109 views
0

請看看以下的Android XML文件,該文件是負責創建GUI無法滾動

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"> 


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

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/imageTitle" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="14dp" 
     android:text="@string/imageDate" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="match_parent" 
     android:layout_height="254dp" 
     android:layout_weight="0.34" 
     android:src="@drawable/test_image" /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="fill_parent" 
     android:layout_height="136dp" 
     android:text="@string/imageDescription" /> 

</LinearLayout> 
</ScrollView> 

我試圖滾動整個屏幕,但它沒有發生。上傳的圖片將清楚地向您說明。爲什麼它不滾動?我是android新手,這是我的第二個應用程序。請幫忙! Inside eclipse Inside Android run

+0

使用'wrap_content'您的LinearLayout – Praveenkumar 2012-07-27 06:01:57

+0

實際上它需要WRAP_CONTENT即使我們給FILL_PARENT我猜。因爲在我的應用程序中,當我使用fill_parent時,它會要求使它成爲wrap_content,而我沒有,它仍然正常工作 – 2012-07-27 06:05:58

回答

1

更改使用WRAP_CONTENT這2這樣

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


<TextView 
    android:id="@+id/textView3" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/imageDescription" /> 
+1

它工作正常!非常感謝您的幫助! – 2012-07-27 06:19:40

1

我想你應該在的LinearLayout

2

使用滾動視圖,如果u有整個視圖是滾動的,使用滾動視圖作爲父級佈局並使用這樣的代碼。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true"> 

這裏android:fillViewport="true"這是允許u到填滿整個屏幕布局重要組成部分。如果有其他問題問。

至於android.developer說,對fillViewport Defines whether the scrollview should stretch its content to fill the viewport.

+0

感謝您的建議。我會記住:) – 2012-07-27 06:20:21