2

I am doing the tablelayout with ScrollView. In this code GridView also in TableLayout but I am not getting the ScrollView for GridView. Pls help me. The problem is coming at GridView.

  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="horizontal" >

<TableLayout
    android:id="@+id/TableLayout1"
    android:layout_width="532dp"
    android:layout_height="257dp"
    android:layout_gravity="right"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    tools:context=".Intcalc" >

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="10dp" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="To Date"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttodate"
            android:layout_width="160dp"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="date"
            android:onClick="selectDate" />

        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:onClick="selectDate"
            android:src="@android:drawable/btn_star" />
    </TableRow>
     <GridView
        android:id="@+id/gridView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:numColumns="3"
        >
     </GridView>

       </TableLayout>

      </ScrollView>
Cœur
  • 34,719
  • 24
  • 185
  • 251
Andrio
  • 41
  • 6

4 Answers4

0

Gridview already has a scrollbar of its own so it'll be painfull if you again surround it inside another scrollbar.

Akanksha Hegde
  • 1,698
  • 11
  • 14
0

1st thing you never use two scroll together in android. Scroll-view is also provide scroll and Grid-view is also provide scroll. In your condition you need to improve your logic is with scroll-view or with grid-view.

Simmant
  • 1,428
  • 25
  • 39
  • I am using scrollview for tablelayout and insert gridview in tablerow so i want scrool for main activity and gridview also – Andrio Apr 25 '14 at 07:03
0

check below link:-

How can I put a ListView into a ScrollView without it collapsing?

It resolve my problem on list view so check it and implement it.

Community
  • 1
  • 1
duggu
  • 37,191
  • 12
  • 114
  • 111
0

I am Using this logic thanks for help

         GridView gridView=(GridView)findViewById(R.id.gridView1);

      gridView.setOnTouchListener(new GridView.OnTouchListener() 
      {

            public boolean onTouch(View v, MotionEvent event)
            {
                int action = event.getAction();
                switch (action) {
                case MotionEvent.ACTION_DOWN:
                    // Disallow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    break;

                case MotionEvent.ACTION_UP:
                    // Allow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
                }

                // Handle ListView touch events.
                v.onTouchEvent(event);
                return true;
            }
        });
Andrio
  • 41
  • 6