quot;The type Gallery is deprecatedquot;, Whats the best alternative?(“不推荐使用 Gallery 类型,最好的选择是什么?)
问题描述
我真的很惊讶这样的 Widget 被弃用了.
我想要一个简单的画廊,左右滚动,在整个活动屏幕上显示一张图片,最重要的是你不能在任何方向滑动超过 1 个图像,即使滚动速度很快它也会改变到下一个图像.
I was really surprised that such a Widget gets deprecated.
I want a simple gallery that scrolls left and right, shows a picture on the whole Activity screen, and most important is that you cant swipe more than 1 image in any direction, even if the scroll speed is fast it changes to the next image.
那么我应该使用哪个小部件?还是应该使用简单的 ImageView 并处理所有滑动并添加动画?
So which Widget should I use? Or should I use a simple ImageView and handle all the swipes and add an animation?
推荐答案
它在文档中声明:
不再支持此小部件.其他水平滚动小部件包括支持库中的 HorizontalScrollView 和 ViewPager.
This widget is no longer supported. Other horizontally scrolling widgets include HorizontalScrollView and ViewPager from the support library.
HorizontalScrollView 会更接近我认为的您要查找的内容.
HorizontalScrollView will be closer to what you are looking for I think.
我怀疑 Gallery 已被弃用,因为它没有正确使用 convertView 及其适配器.这意味着它必须为每个项目创建一个新视图,这会消耗性能.
I suspect that Gallery was deprecated because it did not properly use convertView with its adapter. Which meant that it had to create a new view for every item which was a drain on performance.
您的另一个选择是使用 Joseph Earl 创建的 第三方创建的 EcoGallery问题,这个版本确实正确地回收了它的视图.不幸的是,pastebin link 是我现在在网上能找到的唯一参考.
Another option you have is to use the 3rd party created EcoGallery which Joseph Earl created to overcome the issue, this version does recycle its views properly. Unfortunately that pastebin link is the only reference to it I can find online now.
这篇关于“不推荐使用 Gallery 类型",最好的选择是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“不推荐使用 Gallery 类型",最好的选择是什么?


- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01