在静态滚动视图中在屏幕上显示一项
我想创建一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您好,请尝试将此添加属性添加到您的 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