Thanks Dianne,
 But i dint understand what you meant by this :
"but it is entirely implementable with the SDK.". Could you please
explain.

I also want to know whether the approach i am following is correct one
or is there a better approach.
So far i have tried to draw  a curved line and was able to place some
text(not TextViews) along the path at specific intervals.
I was also able to place a drawable on the center Text.
The things to be implemented are :
a) Give click property to every text along the path
b) update the list of text with the new list on UP or DOWN key press.

The problem i am facing right now is :
a) the onDraw is getting called in an infinte loop. (I tried to set a
flag but then it is drawing and in the next instant the screen gets
cleared)
b) i am not getting the onKey functionalities.


Please find my code below :
package com.android.mygallery;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PixelFormat;
import android.graphics.PointF;
import android.graphics.RectF;
import android.graphics.Matrix.ScaleToFit;
import android.graphics.Paint.Style;
import android.graphics.Path.Direction;
import android.graphics.drawable.BitmapDrawable;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnKeyListener;
import android.widget.Gallery;
import android.widget.ImageView.ScaleType;

public class MyCurvedGallery extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                requestWindowFeature(Window.FEATURE_NO_TITLE);

                getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

                getWindow().setFormat(PixelFormat.TRANSPARENT);
                myView view = new myView(this);
                view.requestLayout();
                setContentView(view);

        }

        class myView extends View implements OnKeyListener{

                private Paint myPaint;

                boolean completeFlag = false;

                public myView(Context context) {
                        super(context);

                        myPaint = new Paint();
                        myPaint.setAntiAlias(true);
                        myPaint.setStyle(Style.STROKE);
                        myPaint.setStrokeWidth(2);
                        myPaint.setColor(Color.WHITE);
                        myPaint.setTextSize(30);

                        this.setOnKeyListener(this);

                }


                protected void onDraw(Canvas canvas) {
                        canvas.drawColor(Color.BLACK);

                        PointF mPoint1 = new PointF(600, 30);
                        PointF mPoint2 = new PointF(2500, 700);
                        PointF mPoint3 = new PointF(300, 1070);
                        Path myPath = new Path();
                        Path myPath2 = new Path();
                        Matrix m = new Matrix();

                        myPath = buildPath(mPoint1, mPoint2);
                        myPath2 = buildPath(mPoint2, mPoint3);

                        myPath2.addPath(myPath);

                        Bitmap myBitmap = 
BitmapFactory.decodeResource(this.getResources(),
                                        R.drawable.selector3);

                        int width = myBitmap.getWidth();

                        int height = myBitmap.getHeight();

                        int newWidth = 350;
                        int newHeight = 200;


                        float scaleWidth = ((float) newWidth) / width;
                        float scaleHeight = ((float) newHeight) / height;

                        m.postScale(scaleWidth, scaleHeight);
                        m.postRotate(51);

                        Bitmap resizedBitmap = Bitmap.createBitmap(myBitmap, 0, 
0, width,
                                        height, m, true);

        //              if(completeFlag == false)
                                drawBitmapAlongPath(myPath2, resizedBitmap, 
canvas, m);
                        invalidate();
                }

                private Path buildPath(PointF mPointa, PointF mPointb) {
                        Path myPath = new Path();
                        myPath.moveTo(1300, 30);
                        myPath.quadTo(mPointa.x, mPointa.y, mPointb.x, 
mPointb.y);
                        return myPath;
                }

                void drawBitmapAlongPath(Path myPath, Bitmap myBitmap, Canvas
canvas,
                                Matrix m) {

                        PathMeasure meas = new PathMeasure(myPath, false);
                        final int length = (int) meas.getLength();
                        final int advance = 250;
                        int distance = 0;

                        final int flags = PathMeasure.POSITION_MATRIX_FLAG
                                        | PathMeasure.TANGENT_MATRIX_FLAG;

                        int i = 1;

                        while (distance < length) {
                                meas.getMatrix(distance, m, flags);

                                float myMatrixArray[] = new float[9];

                                m.getValues(myMatrixArray);

                                if (4 == i) {
                                         float [] myArray =
                                         {0.5f,0.5f,myMatrixArray[2]-100,-0.5f,
0.5f,myMatrixArray[5]-10,0,0,1};
                                        Matrix src = new Matrix();
                                        src.setValues(myArray);
                                        m.set(src);
                                        canvas.drawBitmap(myBitmap, m, myPaint);
                                }
                                canvas.drawText("Position - " + i++, 
myMatrixArray[2],
                                                myMatrixArray[5], myPaint);

                                distance += advance;
                        }
                        completeFlag = true;
                }

                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                        System.out.println("MyCurvedGallery.onKey()");
                        switch (keyCode) {
                        case KeyEvent.ACTION_UP:
                                
System.out.println("MyCurvedGallery.onKey().ACTION_UP");
                                break;
                        case KeyEvent.ACTION_DOWN:
                                
System.out.println("MyCurvedGallery.onKey().ACTION_DOWN");
                                break;

                        default:
                                break;
                        }
                        return false;
                }
        }
}

Please help.

Thanks & Regards,
Sen



On Sep 20, 1:11 am, Dianne Hackborn <[email protected]> wrote:
> I'd suggest taking the platform's code for the gallery and modifying it to
> do what you want.  You'll need to tweak some things to be able to build it
> against the SDK, but it is entirely implementable with the SDK.
>
>
>
> On Sun, Sep 19, 2010 at 8:03 AM, Navaneeth <[email protected]> wrote:
> > Hi All,
> > Is it possible to change the default arrangement of the Android
> > Gallery? What i meant is can we make the Gallery in a curved path,
> > where the images will be along the curved path and the same time it
> > has all the properties of the Android gallery(which appears to be
> > center locked and horizontal right now..)?
>
> > If possible, please tell me your ideas. All ideas are welcome.
>
> > Thanks & Regards,
> > Sen
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to