简体   繁体   English

在屏幕上以 static 滚动视图显示一项

[英]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.我只想创建一个 android 应用程序的前端,它可以显示滚动视图的工作方式,滚动视图一次只显示一个布局或一个项目(例如,在 Instagram 应用程序中,从一个帖子移动到另一个)这意味着屏幕上一次只有一个完整的帖子,而不是当你向上滑动一次时有两个半帖子。

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.此外,它只有 static 数据,并且在后台不使用回收器视图或适配器,因此必须使用滚动视图选项或任何其他替代方案(如果您知道)。

activity_main.xml 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"您好,请尝试将此添加属性添加到您的 ScrollView android:fillViewport="true"

You can get brief answer from this question你可以从这个问题得到简短的回答

Thank for Hardik Parsania for this helpful post感谢 Hardik Parsania这篇有用的帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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