Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fragment inside scrollView

I need to have a arrayAdapter (fragment) inside a scroll view with buttons underneath, Unfortunately, when doing that my fragment have the size of one element and is scrolling himself

here is my view:

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <fragment
            android:id="@+id/myfragment"
            android:name="com.myapply.MyListFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="clip_vertical" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TEST TEST TEST"
            android:textColor="#FFFFFF"
            android:textSize="25dp" />
    </LinearLayout>
</ScrollView>

any help will be welcome

like image 237
gaymer Avatar asked Nov 13 '22 04:11

gaymer


1 Answers

Short answer is that you cannot have a ListView inside a ScrollView. Here is a related SO thread.

Looking at your layout you could redesign it to a RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <fragment
            android:id="@+id/myfragment"
            android:name="com.myapply.MyListFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="clip_vertical"
            android:layout_above="@+id/bottomTextView" />

        <TextView
            android:id="@+id/bottomTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TEST TEST TEST"
            android:textColor="#FFFFFF"
            android:layout_alignParentBottom="true"
            android:textSize="25dp" />

</RelativeLayout>
like image 69
gunar Avatar answered Nov 15 '22 07:11

gunar