1

i want to create a Frame layout to place a number of images from database, which need to be a horizontal scrollable list. Image Views are creating dynamically based on database value. Images must be overlapped like the attachment . Here is my xml

 <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true" 
                android:layout_marginTop="20dp"
                >

            <FrameLayout
                android:id="@+id/frmLayout"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:scrollbars="horizontal"
                android:layout_weight="1"
                 >

            </FrameLayout>

        </HorizontalScrollView>

and Here is java

public void getAllImages(){

        cursorImages = dbAdapter.fetchImages();
        if (cursorImages.moveToFirst()) {
           BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize = 2;
        do {
            String filename = cursorImages.getString(cursorImages
                    .getColumnIndex("filename"));
            try {
                InputStream ims = getAssets().open("images/" + filename);
                Bitmap bm = BitmapFactory.decodeStream(ims,null,options);
                Matrix mat = new Matrix();
                mat.postRotate(30);
                Bitmap bMapRotate = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), mat, true);
                 ImageView im = new ImageView (this);
                 im.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));  
                 im.setImageBitmap(bMapRotate);
                 frmLayout.addView(im,new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));       
            } catch (IOException ex) {

            }
        } while (cursorImages.moveToNext());

    }
    cursorImages.close();

 }

Screen 1 SCreen 2

i leaf
  • 273
  • 7
  • 19
  • If each of those cards is an `ImageView` then you can't do that with any of the standard `ViewGroups`(like `FrameLayout`, who will stack views one on top of the others). You'll have to make your own `ViewGroup` subclass and put the `ImageViews` like you want. Note that isn't something easy to do. – user May 08 '12 at 11:14
  • @Luksprog is there any other way to implement it rather than ImageView and view group?. Can i use custom view to draw bitmap. But the problem is i have to replace the clicked bitmap with new one – i leaf May 09 '12 at 03:58
  • You could try to make a custom `View` and draw the images yourself but again, it won't be an easy task to do if you plan to replace them later. – user May 09 '12 at 04:47
  • Thanks for your comments. I have done it using Relative layout and set margins to margin += imagewidth/2 . – i leaf May 09 '12 at 06:30

0 Answers0