简体   繁体   中英

Show one item at screen in a static scroll view

I want to create just the front-end of an android app which can show the working of a scroll view in a way that scroll view shows only one layout or one item at a time ( For eg. in Instagram application moving from one post to another) which means there is only one complete post on the screen at a time rather than two half post when you just swipe up once.

Also it's just static data and no use of recycler view or adapter in background so have to work with scroll view option or any other alternative if you know.

activity_main.xml

  <ScrollView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_below="@+id/toolbar"
  android:scrollbars="none"
  android:id="@+id/scrollView"

  >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >

  <include layout="@layout/layout_text_feed" />

  <include layout="@layout/layout_image_feed" />

  <include layout="@layout/layout_text_feed" />

  <include layout="@layout/layout_image_feed" />

  <include layout="@layout/layout_text_feed" />

  <include layout="@layout/layout_image_feed" />

  <include layout="@layout/layout_text_feed" />

  <include layout="@layout/layout_image_feed" />

  <include layout="@layout/layout_text_feed" />
</LinearLayout>

These are two types of layout files one having just text and other having image and are just randomly arranged to give a prototype of a feed.

Hi please try to add this add attribute to your ScrollView android:fillViewport="true"

You can get brief answer from this question

Thank for Hardik Parsania for this helpful post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM