【问题标题】:Slide Images into the view Like a gallery in android像 android 中的画廊一样将图像滑入视图
【发布时间】:2014-11-03 19:00:06
【问题描述】:

我想在我的应用程序的第一页显示固定数量的images (say 3),就像画廊一样。使用计时器我每分钟下载一次新图像。该图像应从右侧滑入,将现有图像向左移动。这意味着第一个图像从屏幕上消失,新图像作为最后一个出现。如果消失的图像被处理掉就更好了。

问题

  1. 我希望图像适应屏幕尺寸,这样对于任何屏幕尺寸,我都可以始终显示 3 张图像。
  2. 我尝试使用水平滚动视图,虽然我可以添加视图,但我找不到在保持正确滚动位置的同时删除消失的视图的方法。

最好的方法是什么。使用animations 是不是更好?

谢谢

【问题讨论】:

  • 您可以使用HorizontalScrollView
  • 谢谢,我试过了,但无法正确维护位置。我删除了消失的那个并添加了新的,但滚动没有继续。

标签: android android-layout android-imageview horizontalscrollview


【解决方案1】:

你可以试试这个方法

public class ImageDisplay extends Activity{
String image_url;
private Gallery gallery;
ArrayList<String>image_list=new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_display);

    Intent in=getIntent();
    image_url=in.getExtras().getString("image_url");
    image_list = in.getStringArrayListExtra("all_image_url");


    gallery = (Gallery) findViewById(R.id.Gallery);     
    gallery.setAdapter(new MainActivity().new AddImgAdp(ImageDisplay.this,image_list.toArray(new String[image_list.size()])));

}
}

输出

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-23
  • 1970-01-01
相关资源
最近更新 更多