3
我試圖把一些內容(在這種情況下,與ID'底部內容的LL')在屏幕的底部和當用戶開始滾動我喜歡在底部顯示更多的內容它。任何想法如何做到這一點?我有下面的代碼,但沒有滾動,因爲下面的「bottomcontent」的LL得到高度= 0alignparentbottom爲scrollview內的relativelayout
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>
感謝您的回答,但那不完全是。沒有停滯的部分。只有當用戶向上滾動時才應該顯示LL。 LL在屏幕下方並且在滾動時可用 – user3030130 2014-09-22 20:27:19
那麼它是否在ScrollView的末尾,並且僅在滾動時才顯示給用戶? – 2014-09-22 20:43:50
LL是scrollview的一部分,但是它的最後一個視圖。如果這就是你在scrollview結尾的意思,那麼是的。 – user3030130 2014-09-22 20:52:32