Lisa Anne
Lisa Anne

Reputation: 4595

Why this ScrollView doesn't scroll?

Thank for your help.

I have a GridView.

Each item of the GridView consists in this layout:

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

At runtime I add programmatically TextViews as children on the 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);

                    }

                }

But inside the cell no scrolling happens.

enter image description here

Thank you very much for your help!!!

Upvotes: 0

Views: 1030

Answers (1)

Ben Kane
Ben Kane

Reputation: 10030

Set your ScrollView height to wrap_content. The ScrollView needs to be able to be bigger than it's parent for it to scroll.

Upvotes: 1

Related Questions