简体   繁体   中英

How scroll a layout view in android studio?

How to have multiple layouts (eg. Relative layouts) stacked one above other (each contains text and images regarding news) and move up/down or animate the top most layout by scrolling action in android studio. Please see this screenshot to kmow what i am talking about https://drive.google.com/file/d/1MrqgKn7CEVuZwkMi8a6ZZB0MXxR3w10R/view?usp=drivesdk

此处的图像描述 in the new version of Android studio you can resize your preview layout by drag it. try this

There's a few ways to accomplish this.

Option 1: Dynamic content - Utilize a Recycler view - In your ViewHolders, use your RelativeLayouts as the layouts to inflate.

Option 2: Static Content - Utilize a ScrollView root - Utilize a vertical LinearLayout with height of wrap_content. - Stack your RelativeLayouts.

Option 3: Another Static Content Option - Utilize a ScrollView - Utilize a RelativeLayout child - Utilize your RelativeLayout childs inside the previous RelativeLayout and use layout_below in each of them.

(Extra info: Consider using ConstraintLayout or something else in place of RelativeLayout to avoid the double measurement issue with RelativeLayout)

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