愿所有的美好和期待都能如约而至

“不推荐使用 Gallery 类型",最好的选择是什么?

发布时间:  来源:互联网  作者:匿名  标签:android error "The type Gallery is deprecated" excepti  热度:37.5℃

本文介绍了“不推荐使用 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?

推荐答案

它在文档中声明:

不再支持此小部件.其他水平滚动小部件包括支持库中的 Horizo​​ntalScrollView 和 ViewPager.

This widget is no longer supported. Other horizontally scrolling widgets include HorizontalScrollView and ViewPager from the support library.

Horizo​​ntalScrollView 会更接近我认为的您要查找的内容.

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 类型",最好的选择是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,

勇敢去编程!

勇敢的热爱编程,未来的你一定会大放异彩,未来的生活一定会因编程更好!

TOP