Android图库水平滚动
我有一个包含图像的画廊,当水平滚动时,会滚动多个图像而不是一个。
以下是我的代码的一部分:
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (convertView == null) {
view = inflater.inflate(resourceid, null);
}
synchronized (view) {
TextView txtTitle = (TextView) view
.findViewById(R.id.txtCaption);
ImageList item = getItem(position);
ImageView ivImage = (ImageView) view.findViewById(R.id.ivImage);
ivImage.setScaleType(ScaleType.CENTER_INSIDE);
try {
ivImage.setImageBitmap(getBitmapFromAsset(item.imageUrl));
}
I have a gallery with images and when scroll horizontally, multiple images are scrolled instead of one.
Below is part of my code:
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (convertView == null) {
view = inflater.inflate(resourceid, null);
}
synchronized (view) {
TextView txtTitle = (TextView) view
.findViewById(R.id.txtCaption);
ImageList item = getItem(position);
ImageView ivImage = (ImageView) view.findViewById(R.id.ivImage);
ivImage.setScaleType(ScaleType.CENTER_INSIDE);
try {
ivImage.setImageBitmap(getBitmapFromAsset(item.imageUrl));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个解决方案效果很好。
PS:你需要扩展一个Gallery。
This solution works perfectly.
PS: You need to extends a Gallery.
对于已创建自定义图库的用户,可以参考此处的示例
来减慢速度向下快速导航您的画廊尝试下面的代码
for that you have create custom gallery you can refer the example here
to slow down fast navigation of your gallery try below code