2013-08-30 46 views
0

感謝您的幫助。爲什麼這個ScrollView不滾動?

我有一個GridView。

在GridView的每個項目包含在這個佈局:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/black" 
android:padding="2dip" > 

<TextView 
    android:id="@+id/date" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:text="29" 
    android:textColor="@android:color/white" 
    android:textSize="14dip" 
    android:textStyle="bold" /> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/date" > 

    <LinearLayout 
     android:id="@+id/layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 
    </LinearLayout> 
</ScrollView> 

在運行時我添加編程TextViews兒童在的LinearLayout

ll = (LinearLayout) v.findViewById(R.id.layout); 
for (int j = 0; j < eventi.size(); j++) { 
        if (eventi.get(j).day.equalsIgnoreCase(date)) { 
         TextView tv = new TextView(mContext); 
         tv.setText("■ "+eventi.get(j).title); 
         tv.setTextSize((parent.getHeight()/(getCount()/7)/15)); 
         tv.setTextColor(mContext.getResources().getColor(R.color.darkbluetheme)); 
         ll.addView(tv); 

        } 

       } 

但在細胞內沒有滾動發生。

enter image description here

非常感謝您對您的幫助!

+2

不要嵌套滾動視圖,它幾乎永遠不會結束。 – kabuko

+0

@kabuko :-)))是的,但在這種情況下,它應該工作! –

+0

你甚至需要一個gridview嗎?對於一個日曆,你總是需要7列5行(除非星期天在非閏年開始的2月份,然後你可以使用4)。你可以使用TableLayout,或者甚至嵌套LinearLayouts。當你不確切知道有多少行/列會需要滾動選項時,GridView是最好的選擇。 – Geobits

回答

1

將您的ScrollView高度設置爲wrap_contentScrollView需要能夠比它的父級更大才能滾動。

+0

謝謝,工作! –

+0

不是問題:) –