0

我使用了画廊视图,我在其中动态放置了多个图像视图,但是在单击图像视图时它位于中心,第二个问题是如何从屏幕左侧开始第一个图像视图。

在用户用手指水平滚动之前,我不想更改位置。有什么办法可以做到这一点。请帮忙。。

private  class ImageAdapter extends BaseAdapter{

     public ImageAdapter() {
        //To set blank at bottom and make visible
        TextView textView = (TextView)findViewById(R.id.textView2);
        textView.setVisibility(View.VISIBLE);

        //To set the visibility visible of gallery
        myGallery.setVisibility(View.VISIBLE);
     }

     public int getCount() {
         return ProductItemArray.Image_URL.length;
     }

     public Object getItem(int position) {
         return null;
     }

     public long getItemId(int position) {
         return 0;
     }

     public View getView(int position, View arg1, ViewGroup arg2) {
         ImageView bottomImageView = new ImageView(context);

         if(Helper.isTablet(context))
             bottomImageView.setLayoutParams(new Gallery.LayoutParams(VirtualMirrorActivity.convertDpToPixel(100, context), VirtualMirrorActivity.convertDpToPixel(100, context)));
         else
             bottomImageView.setLayoutParams(new Gallery.LayoutParams(VirtualMirrorActivity.convertDpToPixel(80, context), VirtualMirrorActivity.convertDpToPixel(80, context)));

         UrlImageViewHelper.setUrlDrawable(bottomImageView, ProductItemArray.Image_URL[position]);
         bottomImageView.setBackgroundResource(R.layout.border);

         return bottomImageView;
     }

}

myGallery.setAdapter(new ImageAdapter());
myGallery.setSelection(1);
myGallery.setOnItemClickListener(new OnItemClickListener()
{
    @Override
    public void onItemClick(AdapterView<?> parent, View view, final int position, long arg3)
    {
        linearLayout.removeView(frameImageView);
        Thread newThread = new Thread(new Runnable() {
            public void run() {
                URL url_1 = null;
                try {
                    isAlreadyExistInWishlist = false;
                    VMProductListPaging.productUrl = ProductItemArray.Image_small_URL[position];
                    VMProductListPaging.productId = ProductItemArray.productId[position];
                    VMProductListPaging.productName = ProductItemArray.product_Name[position];

                    url_1 = new URL(ProductItemArray.Image_small_URL[position]);
                    bmp = BitmapFactory.decodeStream(url_1.openConnection().getInputStream());
                    isExecuted = true;
                    bitmapHandler.sendMessage(bitmapHandler.obtainMessage());
                }
                catch (Exception e) {
                    //Toast.makeText(context,"Sorry!! This link appears to be broken",Toast.LENGTH_LONG).show();
                }
            }
        });
        newThread.start();
    }
});

布局.xml

<Gallery android:id="@+id/galleryView"  android:layout_width="fill_parent" android:layout_height="wrap_content"  
    android:spacing="5dp" android:layout_below="@+id/sendPhoto" android:layout_marginTop="10dp" android:visibility="gone"/> `enter code here`
4

1 回答 1

0

这个画廊小部件锁定在视图的左侧而不是中心。

https://github.com/TheLevelUp/android-left-locked-gallery

于 2012-12-18T12:44:27.117 回答