簡體   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