【问题标题】:android gallery horizontal scrolling. Help pleaseandroid 图库水平滚动。请帮忙
【发布时间】:2011-10-27 21:45:01
【问题描述】:

我有一个包含图像的画廊,当水平滚动时,会滚动多个图像而不是一个。请帮我解决这个问题 以下是我的代码的一部分。提前致谢

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));

}

【问题讨论】:

    标签: android scroll gallery


    【解决方案1】:

    对于您已经创建自定义图库,您可以参考示例 here

    要减慢画廊的快速导航速度,请尝试以下代码

    yourGallery.setCallbackDuringFling(false);
    

    【讨论】:

    • 感谢您的信息,但我已经这样做了,但它仍然一样,可以显示一些示例代码
    • 我已经给了亲爱的链接,只是修改它
    【解决方案2】:

    此解决方案完美运行。

    PS:你需要扩展一个画廊。

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        int kEvent =
                e1.getX() < e2.getX() ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT;
        onKeyDown(kEvent, null);
        return true;
    }
    

    【讨论】:

      猜你喜欢
      • 2015-06-08
      • 1970-01-01
      • 1970-01-01
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多