繁体   English   中英

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

[英]Show one item at screen in a static scroll view

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

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

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>

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

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

你可以从这个问题得到简短的回答

感谢 Hardik Parsania这篇有用的帖子

暂无
暂无

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

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