[android-developers] Re: Image viewers on android phones not always the best experience?
I would recommend implementing a custom view class which extends ImageView and overrides the onTouch event. Take a look at Luke Hutch's MultiTouchController http://lukehutch.wordpress.com/2010/01/06/my-multi-touch-code-ported-to-eclair/ and samples. This will be a) Quicker to load b) Use less memory c) Give you multi-touch pinch-zoom On Jul 15, 9:35 pm, Mark Wyszomierski wrote: > Hi, > > I'm trying to use animage-display intent to..display animage: > > Uri uri = ...; > Intent intent = new Intent(android.content.Intent.ACTION_VIEW); > intent.setDataAndType(uri, "image/" + extension); > startActivity(intent); > > this works well, but some devices haveimageviewers that handle this > intent which are sub-optimal. For example, on the Nexus One, it looks > like animagegallery application starts up - this takes about 10+ > seconds before showing theimage. On the Droid, animageapplication > starts up very quickly and shows theimageright away. > > If we shouldn't rely on the above intent to provide a good experience > for the user, is there another method anyone is using? Would just like > to know before I try writing something myself, > > Thanks -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image viewers on android phones not always the best experience?
I see I have some typos in the example above. For example: String[] myImageWithPath should be String myImageWithPath Just thought you should know that this isn't a completely working example. :) Editing may be necessary. Shawn On Jul 17, 11:13 am, nation-x wrote: > I just use an ImageView and resize the image before I display it. Here > is my layout: > > > http://schemas.android.com/apk/res/android"; > android:id="@+id/image" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:scaleType="centerInside" > android:src="@drawable/wait" > /> > > private Display display; > > /* in onCreate */ > display = ((WindowManager) > getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); > > /* add the image to the ImageView */ > String[] myImageWithPath = "/sdcard/DCIM/image.jpg"; > > ImageView image = (ImageView)findViewById(R.id.image); > image.setImageDrawable(getScaledDrawable(myImageWithPath)); > > private int getScreenWidth() { > int width = display.getWidth(); > return width; > > } > > private int getScreenHeight() { > int height = display.getHeight(); > return height; > > } > > private Drawable getScaledDrawable(String imagePath) { > Bitmap scaledBitmap = null; > BitmapFactory.Options options=new BitmapFactory.Options(); > options.inSampleSize = 2; > Bitmap origBitmap = BitmapFactory.decodeFile(imagePath, options); > > int oWidth = origBitmap.getWidth(); > int oHeight = origBitmap.getHeight(); > > int screenwidth = getScreenWidth(); > int screenheight = getScreenHeight(); > > /* Scale the image according to orientation */ > if ((oWidth > screenwidth) && (oHeight > screenheight)) { > switch (display.getOrientation()) { > case PORTRAIT: > int factor = screenwidth / oWidth; > int new_height = factor * oHeight; > scaledBitmap = > Bitmap.createScaledBitmap(origBitmap,screenwidth, > new_height, true); > break; > case LANDSCAPE: > factor = screenheight / oHeight; > int new_width = factor * oWidth; > scaledBitmap = > Bitmap.createScaledBitmap(origBitmap,new_width, > screenheight, true); > break; > } > } > else { > /* Image doesn't need to be resized */ > return Drawable.createFromPath(imagePath); > } > System.gc(); > return new BitmapDrawable(getResources(), scaledBitmap); > > } > > On Jul 16, 4:08 pm, "Maps.Huge.Info (Maps API Guru)" > > wrote: > > You can do whatever you want to with webview. It's a browser, well > > sort of, and as such, a little css/html/JavaScript will do just about > > anything. > > > -John Coryat > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image viewers on android phones not always the best experience?
I just use an ImageView and resize the image before I display it. Here is my layout: http://schemas.android.com/apk/res/android"; android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="centerInside" android:src="@drawable/wait" /> private Display display; /* in onCreate */ display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); /* add the image to the ImageView */ String[] myImageWithPath = "/sdcard/DCIM/image.jpg"; ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(getScaledDrawable(myImageWithPath)); private int getScreenWidth() { int width = display.getWidth(); return width; } private int getScreenHeight() { int height = display.getHeight(); return height; } private Drawable getScaledDrawable(String imagePath) { Bitmap scaledBitmap = null; BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 2; Bitmap origBitmap = BitmapFactory.decodeFile(imagePath, options); int oWidth = origBitmap.getWidth(); int oHeight = origBitmap.getHeight(); int screenwidth = getScreenWidth(); int screenheight = getScreenHeight(); /* Scale the image according to orientation */ if ((oWidth > screenwidth) && (oHeight > screenheight)) { switch (display.getOrientation()) { case PORTRAIT: int factor = screenwidth / oWidth; int new_height = factor * oHeight; scaledBitmap = Bitmap.createScaledBitmap(origBitmap,screenwidth, new_height, true); break; case LANDSCAPE: factor = screenheight / oHeight; int new_width = factor * oWidth; scaledBitmap = Bitmap.createScaledBitmap(origBitmap,new_width, screenheight, true); break; } } else { /* Image doesn't need to be resized */ return Drawable.createFromPath(imagePath); } System.gc(); return new BitmapDrawable(getResources(), scaledBitmap); } On Jul 16, 4:08 pm, "Maps.Huge.Info (Maps API Guru)" wrote: > You can do whatever you want to with webview. It's a browser, well > sort of, and as such, a little css/html/JavaScript will do just about > anything. > > -John Coryat -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image viewers on android phones not always the best experience?
You can do whatever you want to with webview. It's a browser, well sort of, and as such, a little css/html/JavaScript will do just about anything. -John Coryat -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Image viewers on android phones not always the best experience?
I have to check again, but I thought webview won't center and zoom a single image for you. It will just show the full size image, if it's larger than the phone screen, it'll just scroll off. On Thu, Jul 15, 2010 at 4:33 PM, Maps.Huge.Info (Maps API Guru) < cor...@gmail.com> wrote: > You can always use a webview. It's pretty easy to write your own > method or use the default. Images in webview seem to work quite well > and start fairly fast. > > -John Coryat > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image viewers on android phones not always the best experience?
You can always use a webview. It's pretty easy to write your own method or use the default. Images in webview seem to work quite well and start fairly fast. -John Coryat -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en