在静态滚动视图中在屏幕上显示一项

发布于 2025-01-13 18:59:18 字数 1179 浏览 1 评论 0原文

我想创建一个 Android 应用程序的前端,它可以以滚动视图一次仅显示一个布局或一个项目的方式显示滚动视图的工作方式(例如,在 Instagram 应用程序中从一篇文章移动到另一个)这意味着屏幕上一次只有一个完整的帖子,而不是当您向上滑动一次时屏幕上会显示两个半帖子。

此外,它只是静态数据,并且在后台不使用回收器视图或适配器,因此必须使用滚动视图选项或任何其他替代方案(如果您知道)。

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>

这是两种类型的布局文件,一种仅包含文本,另一种包含图像,并且只是随机排列以提供提要的原型。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三岁铭 2025-01-20 18:59:18

您好,请尝试将此添加属性添加到您的 ScrollView android:fillViewport="true"

您可以从此 问题 获得简短答案

感谢 Hardik Parsania 的这篇有用的帖子

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文