I have my app working where it comes to a screen with 6 thumbnails. The user will select one and the next screen is a full image. I've accomplished this through an OnClickListener to call a new activity/xml (I'm new at this, sorry if my terminology is a little off).
My question is: is there a way to avoid creating 6 activty/xml (one for each thumbnail)? ultimately, my app will have about 40 thumbnails that can be selected for full screen view.
I've been trying to follow examples online where it appears that the code is presenting the full image within java instead of referencing an xml file. I've also seen use of Bitmap and BitmapFactory. Is this the way to go?
If the full screen image can be created dynamically within java, will the Back button still work to the user back to the screen with 6 thumbnails?
thanks, J
The simplest approach to take is to pass a reference to the image in the intent you use to launch the full-screen activity.
You can use the BitmapFactory to create a Bitmap, and then update the ImageView (or however you're displaying the image) from the loaded bitmap.
Using this approach, the back button will still work normally, but you'll only need one activity to display the full-screen image.
Related
I have a list of image URLs and have to show them and change them automatically in ImageView and need to count how many times every image appears to the user.
What could be the best approach to do this? can we avoid handlers here?
Android provides views which can be used to display images from various sources and provide transitions between them. Some of these views are the ImageView and the ImageSwitcher. These views provide a high level of functionality to display images in a user interface so that we can concentrate on the images we want to display rather than taking care of rendering.
You can get complete guide setup in links description.
In description there is a complete explaination for changing image using ImageSwitcher
by pressing a button, But by updating the code to change after certain can be done easily.
Link to tutorial:
https://www.sitepoint.com/handling-displaying-images-android/
A github link for application used with image switching button:## Heading ##
https://github.com/Adarshgkp04/Android_Image_transitions.git
Feel free to ask queries.
Okay so this might be a very silly question to ask.
Does a bitmap of an image remains constant traversing through different activities in the android.
Well my issue is :
I have an activity with image view having a default image.
I am previewing another image picked from the gallery if the user wants it.
So now then i move on to the next activity displaying the image user picked from the gallery.
Now if the user hasn't picked any image i want to show another default image.
Please note not the 1st default image in 2nd activity.
If a bitmap remains in the drawables folder, then you can access it from every Activity and it will remain "constant" so to say (if that's what you meant). If you're using the bitmap in the code (to set it as the background of the ImageView), then this can be changed - othwerise if in drawables - it's just usable, you can manipulate it, but you will never change its basic status (in the folder).
I have two situations/projects where I have to use a large bitmap as background activity.
The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.
In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?
Is it possible to crop pictures on Android?
Is it possible to define the part of the picture which is kept?
Is it possible to use this croped pictures as background image or may I encounter performance penalties?
What do you think of this technique? Is it a good idea?
Thanks for your help!
answering your questions:
yes it is possible to crop pictures in Android (I've done so)
you can define wich part of the picture is shown in each activity
with a canvas and only drawing the rect that corresponds to the part
of the image that you want to display (eventough I wouldnt suggest
the approach of having diferent activities with the "same" content)
yes, you can use cropped pictures as background image for whatever
you want. Once you cropped the image use that bitmap and save it in
the device and then you might use it as you wish, and eventought is not recommended to have the whole image as background you can do so.
I suggest that you use a SurfaceView since you will be able to move it (the image) all around the screen without having to create a new activity. Here is a good tutorial to SurfaceView Playing with graphics in Android – Part I and this approach will also work with Tablets.
Here is my problem. I am currently working on an android application that is handling images. When the application first starts, I have a list of categories (Food, Transport, Emergency ...). So I click on a category for example Food. I find myself in the second activity where I have subcategories (Fruit, Meat, Fish ...). So let's say I click on Fruit. I end up in the third activity which displays images (like in a gridview) of different fruits. I can either click on a fruit to zoom it or I can drag & drop it to the bottom of the activity where I have 3 dropzone that are here for me to create a sequence of images and save it.
So back to my problem, when I zoom on an image I want to be able to add a drawing feature. I want to be able to draw on the image when I click on the menu button of the phone and when I select "Draw". I tried to draw on an image but the drawing lines are always going underneath the pictures so I can't see them. Besides, I want to be able to save the image afterwards and I can't seem to find a way to my problem.
Could someone help me please?
I tried using BitmapFactory but it got me nowhere...
Thank you
Try to use search:
How to draw text On image?
How to draw a Line in ImageView on Android?
https://stackoverflow.com/search?q=android+Draw+on+an+image
I am new to android, I have learned how to display drawable pic in gallery,
and display a url pic use ImageView. Now I dont know how to display online pictures in gallery. Should I use listview or not? In addtion, I want to know how to get pictures urls from flickrs with given userid
Do you mean like a photo gallery? is that what your app is supposed to do? Then, yes you could use a ListActivity/ListView. However i do not know if this will provide you with exactly the effect you want. A list view would load ALL of the pictures before the UI could be displayed and you would view them by scrolling. typically a photo viewer shows pictures full screen and switches with either a button or a swipe (gesture).
To get the latter effect, your app could display an ImageView with the first pic while it loads the next pic, and then switch to a new ImageView when the user clicks a button or swipes. this will prevent your app from eating up resources and will give you an interface that people are more used to.
as for flickr, you will have to ask someone else (you should separate these into two separate questions because they are so different)