Search code examples
androidandroid-layoutandroid-linearlayoutandroid-scrollview

Android ScrollView inside LinearLayout


I have problem with layout (buttons) in Andoid. What I want is to display buttons inside ScrollView but the ScrollView must be below a RelativeLayout or with other words, the first two buttons from the ScrollView are not displayed on my phone..

here is the picture: enter image description here

here is my layout:

    <RelativeLayout  android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView android:textAppearance="?android:textAppearanceLarge" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="58.0dip" android:text="@string/naziv" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />
    </RelativeLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/scrollView" >

        <LinearLayout android:layout_gravity="center" android:orientation="vertical" android:paddingLeft="30.0dip" android:paddingTop="90.0dip" android:paddingRight="30.0dip"  android:paddingBottom="20dp" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <Button android:id="@+id/button0"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_veter"  />
            <Button android:id="@+id/button4"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_plimovanje" />
            <Button android:id="@+id/button1"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_trenutni_podatki" />
            <Button android:id="@+id/button5"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_video" />
            <Button android:id="@+id/button2"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_mbp" />
            <Button android:id="@+id/button10"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_wsg"/>
            <Button android:id="@+id/button11"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_ath" />
            <Button android:id="@+id/button12"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_sts" />
            <Button android:id="@+id/button13"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_w" />
            <Button android:id="@+id/button14"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_dotb" />
            <Button android:id="@+id/button15"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_ast" />
            <Button android:id="@+id/button16"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_caw" />
            <Button android:id="@+id/button17"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/gumb_pado" />


        </LinearLayout>
    </ScrollView>



</LinearLayout>

How to diplay a ScrollView below text "morska bioloska postaja..."?

thank you


Solution

  • You need to remove android:layout_gravity="center" from the LinearLayout inside the ScrollView. You might also want to remove its android:paddingTop="90.0dip".