Alignparentbottom for relativelayout inside scrollview

I'm trying to put some content (in this case LL with id "bottomcontent") at the bottom of the screen, and when the user starts scrolling, I like to show more content at the bottom of the screen. Any ideas how to do this? I have the following code, but no scrolling as LL below "bottomcontent" gets height = 0

Here is the code:
<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MyActivity"
        android:background="@android:color/transparent"
        android:fillViewport="true"
        android:layout_alignParentTop="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <!-- I expect this to occupy one full screen, since its child is asking for align parent bottom = true-->
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/transparent"
                android:id="@+id/top">
                <LinearLayout
                    android:id="@+id/bottomcontent"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/holo_green_dark"
                    android:layout_alignParentBottom="true"
                    >

                    <TextView
                        android:text="@string/hello_world"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@android:color/holo_red_light"
                        />
                </LinearLayout>
            </RelativeLayout>
            <!-- When user scrolls, I expect this linear layout to be seen. But I get its height to be zero, so no scrolling-->
            <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"
                >


                <TextView
                    android:text="hello_world hello_world hello_world hello_world hello_world hello_world hello_world "
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:background="@android:color/holo_blue_dark"
                    />
            </LinearLayout>

        </LinearLayout>
    </ScrollView>

      

+3


source to share


1 answer


What I got from your question is that you want scrolling, but you want LL to appear at the bottom of the screen. Even when the user scrolls, LL should show at the bottom, right? You can try the following layout.

<RelativeLayout>
    <ScrollView>
        <RelativeLayout>
            <!--...everything you want to show in scrollview -->
        </RelativeLayout>
    </ScrollView>

    <LinearLayout
        <!--...your layout which you want to always show at bottom.-->
        android:layout_alignParentBottom="true">
    </LinearLayout>

</RelativeLayout>

      



This will depend on the LL at the bottom and the rest will scroll.

+3


source







All Articles