简体   繁体   中英

Android studio scrollview with clickable "cards" and limiting how many are visible on screen

I'm having trouble implementing a scrollview with card-like elements (basically just rows of imageviews), while also limiting how many are visible on screen at any time. I would like all cards to be the same height, but I only want four to be visible on screen. So obviously if there are more than four, you'd need to scroll down.

I tried nesting linear layouts and fixing layout weights but can't wrap my head around how that design would work on varying screen sizes. I also tried dynamically calculating screen size and setting imageview height to be 1/4 of the screen, but ran into issues with accounting for status bar, action bar, or whatever else may be cluttering the screen.

Is there an easy way of implementing something like this?

A RecyclerView is perfect for your requirement

Advantages

  • Comes as scrollable
  • Lets you decide your own card layout and replicates it

Disadvantage

  • All cards should have same layout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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