Search code examples
androidscrollscrollviewandroid-linearlayout

Android, LinearLayout won't scroll


I am relatively new to android programing. Can anybody tell me why my ScrollView won't scroll?

My activity has implemented OnGestureListener for getting some touch information. But, I tried to disable onGestureListener and it still won't work.

It works outside of the SlidingDrawer. Is it possible to get it work inside of the SlidingDrawer?

I solved it by giving to ScrollView ID and then put that ID in SlidingDrawer android:content="@+id/content".

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:background="@drawable/pozadina_touchpad"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="100dp"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:orientation="vertical" >

            <SlidingDrawer
                android:id="@+id/prosirenje"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:content="@+id/content"
                android:handle="@+id/handle" >

                <Button
                    android:id="@+id/handle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/gumb_slider"
                     />

                <ScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">

                    <LinearLayout
                        android:id="@+id/content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/slider"
                        android:gravity="center"
                        android:onClick="nemaSkrola"
                        android:orientation="vertical" >

                        <Button
                            android:id="@+id/ico_povecalo"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="20dp"
                            android:background="@drawable/ikona_povecalo" />

                        <Button
                            android:id="@+id/ico_desktop"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="20dp"
                            android:background="@drawable/ikona_komp" />

                        <Button
                            android:id="@+id/ico_daljinski"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="20dp"
                            android:background="@drawable/ikona_play" />

                        <Button
                            android:id="@+id/ico_tipkovnica"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="20dp"
                            android:background="@drawable/ikona_tipka" />

                        <Button
                            android:id="@+id/ico_settings"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="20dp"
                            android:background="@drawable/ikona_settings" />

                    </LinearLayout>

                </ScrollView>

            </SlidingDrawer>

        </LinearLayout>

    </LinearLayout>

Solution

  • give some value to scrollView's width and height and try like this

    <ScrollView
        android:id="@id/content"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp">
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout>
    </ScrollView>
    

    please change scrollview id like this:

    android:id="@id/content"
    

    please change handle button id like this:

    android:id="@id/handle"