I am extending Gallery class & displaying scrollable images in a horizontal manner.
I am displaying only on the landscape mode.
For displaying the images , I am using BaseAdapter , since I need to place text & icon over the images.
I am displaying the no of images based on a condition which is set.
I want to put the following conditions.
i> If the no of image to be displayed is 1 , I'll only show a single image on the middle of the screen & there should not be any scrolling.
ii> If the no of images to be displayed is 2 , then both the images should be shown side by side(horizontal) & without any scrolling.
iii> Only if the no of images is equal to or greater than 3 , then images should be displayed in the horizontal manner & scrollable.
How can I handle all the above cases using a single layout xml & by handling the conditions source code.
Kindly provide me your inputs/sample code.
Thanks in advance.
Warm Regards,
CB
well for showing the text and the image you will need to create a custom adapter override the getView method and a custom layout (a linear layout with vertical orientation containing a textView and an ImageView) inside the getView. You can find a lot of examples of doing that on google, its pretty simple.(there is the gallery example on the android developers page that explains this). Hello Gallery
For your conditions you can probably make something like this in the adapter constructor or the actual creation of the adapter in the activity. i think by default it wont be scrollable for 1 item, but for 2 it will be since the gallery centers the selected item... which is pretty lame. and for 3 or more it will work as intended (show a scrollable horizontal list of items).
Hope this helps.
Related
I want a layout that will display images without knowing how many. First i thought of a ScrollView, but don't know how to add different images to it. How can that be done? Or is there any other solution?
How can that be done?
Have the ScrollView wrap around a vertical LinearLayout, into which you add your ImageView widgets.
Or is there any other solution?
ListView. GridView. RecyclerView. ViewPager. And so on.
Depending on how you want to display the images, you can also use GridView : Grid View Android Developpers
There is an example : Gridview with two columns and auto resized images
You don't need to use ScrollView or know the amount of images you're gonna show. Just use a ListView with an ArrayAdapter that binds a List of Bitmaps (images) to your ListView (each item of your ListView is an ImageView). Each time you add a new image to your list, just call notifyDataSetChanged() method of your adapter, that's gonna update your ListView.
Just google for a relevant tutorial. You're gonna see lots of examples.
The thing is, I want to avoid the extra space that normally Gallery view is displaying at the end of the Gallery; like in (Figure 1)
I need to adjust it like Figure 2
How can I achieve that with out using HorizontalListView describe in here or extending Gallery.
Thank you :-)
I am trying to Build a gallery in Android ( Not exactly what is already existing in android , by gallery I mean a set of images being displayed together ).
I want to build something like this :
http://www.simpleviewer.net/tiltviewer/app/
(Ignore the 3d affect.. )
A set of images that can be flipped to see the text behind.
The list of images is dynamic and also the content .( I would be getting the list from web )
Also two images could have been flipped on one side and two can be on the other side.
I initially referred 3dTransition : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Transition3d.html and understood a little about transitions.
Do I have to create 10's of ImageViews according to list and place it dynamically or do I have a better approach.
Referred : Android + Use ViewFlipper to flip individual items within a ListView?
But the list view can show one item in a row.. I want to show two to three items. Also individual Items must be clickable and not the complete row.
referred http://code.google.com/p/shelves/ , to implement multiple items in a list row. So is that the way to go ?
How do I display text ? Inflate layout as many as Imageview ?
Or one layout file would do ? (How ? ).
Finally implemented it in this way :
A GridView as top layout.
Each child layout having a ViewFlipper with two views . one for image and other for text.
I attached an onlClick event on griditem onChildItemClick
Note : the swype (fling) action wouldn't work in this screen due to problems of detecting a fling gesture in a scrollable view. This might help : http://www.jmstudio.org/archives/391 or can look here too Swipe/Fling tab-changing in conjunction with ScrollView?
I want to create simple application like android image gallery but I don't want to display images. I want to display an editTexts and buttons...
My idea is to use android.widget.Gallery. Is it good way to solve this?
My next idea is HorizontalScrollView but here is problems with snaps etc.
Yes, you could do this with Gallery, make an Adapter that returns your layout that contains the EditText and Buttons.
However, you should check out ViewPager
Hi i want to add the particular image for each listView item left side .but that is not included in the listview ,see the image from below link
Image
I understand you are talking about the image with red circle. This is functionality of Iphone and not available in android by default. You will have to create custom listview and make the image part of the list item. It cannot be outside listview. That way it will be difficult to access it later on.
Take one scrollview in taht scrollview take 2 linearlayouts as horizontal and then assign images to one linear layout as vertical and add listview to another layout
Here is a nice article http://blog.sptechnolab.com/2011/02/01/android/android-custom-listview-items-and-adapters. It works.