Is it possible to display two ImageViews within a PageViewer? - android

I have a working ViewPager app which renders an ImageView. This ImageView fills the screen in portrait mode but when the user orientates their device to landscape I wish to display the current ImageView on the left and the next ImageView in the sequene on the right.
Currently in landscape the ImageView is simply displayed in the centre of the screen.
I know that I have to define a res/layout-land version of the PageViewer layout, but more than that I don't know.
Is this possible?
Thanks,
Mark.

I don't think it is possible to display more than 1 view on a viewpager (doesn't matter if youre using horizontal or vertical orientation). What you could try is creating 2 viewpagers, but this may become confusing (updating the positions on both viewpagers.. as I assume you want to update the images like flipping through a book). Viewpagers are quite limiting in that sense.
You can try using a ViewFlipper, instead, which allows more flexibility.

Related

Android Viewpager with dynamic data

There are buttons from the service. I need to show these buttons according to the screen size. Buttons that do not fit on the screen should appear when you scroll to the right using the viewpager. How can I do that.
Sorry, I made the picture by hand.

Android layout that crops rather than resize its children

I am looking for an android layout (if there exists) that can do the following.
2 images that occupies the entire width of the screen, stacked on top of each other. A slider say 2 or three pixels wide that allows a user to slide across the width of the screen revealing or hiding portions of the images.
Note that the layout like slidingPane does not work in this scenario as it resizes the contents in each pane rather than cropping them which is what I want.
To better describe the question here are some images.
Not really a layout, but achieves what I was after.
Added images to textureviews(1,2), added one of the textureviews(2) to a linearlayout. Added the texureView1 and linearlayout to a framelayout such that the linearlayout is on top. To achieve the above said effect the linearlayout and the textureView(2) that it holds is moved in opposite directions.

Which Android layout and view to use for simple image-based game?

I would like to make a simple Android game where a large background image is displayed and some other images are displayed in specific locations over it, where the other images may be clickable.
Here's a quick sample image of what I'm talking about:
The user should be able to tap the soccer player or the moose (ah, the classic "soccer player moose problem"!)
How should I render this screen (which layouts and views?) so the user can interact with it and it will scale properly on different devices?
I would use a RelativeLayout.
You can set the you background image to the layout (fill_parent for height and width).
You can then put your ImageViews, containing your moose and soccer player down on the layout relative to the top or sides of the sceen, or relative to each other (making sure to specify "dp" units for everything). Set the backgrounds of your ImageViews to be transparent, and there won't be a bounding box problem (and/or you can also set your ImageViews alignment to be relative to each other, ensuring they don't overlap).
I think this is the simplest way to do this - it is then super easy to attach onClickListener to your ImageViews in your Activity, and you are done.
This type of layout will work the same on all devices and screen sizes.
There are some small gotcha's with RelativeLayouts, but they are pretty simple once you get into them, and provide fast rendering (since the view hierarchy is usually shallow). Good Luck.
ImageView for the clickable elements seems like a fine choice to me. For the background I would just set your image as the background of the parent layout i.e. RelativeLayout
SurfaceView for the whole thing (with your field as a background) and regular *ImageView*s for added elements. You can easily recover the click coordinates from the SurfaceView and thus know what element has been touched.
SurfaceView might offer you additional possibilities anyway.
For most images, I'd use an ImageView for each one, like FoamyGuy said.
If they're close enough for overlapping bounding boxes to be an issue, you can still use an ImageView for each, but with a variation of this answer, testing alpha for each ImageView in range.
I would agree with both FoamyGuy and Booger that if your only goal is to place static images onto the screen that do something when you click them, RelativeLayout and ImageViews all the way.
But...
If you are looking to randomly spawn multiple images onto the screen in intervals and have them move around for the player to interact with while explosions are going off and maidens are being kidnapped, you should look into SurfaceView, Canvas, Drawable, TouchEvents, and FrameBuffers.

large, long images scrolling across screen at different speeds, and off of the left of the screen

So I have multiple very long images (like 2000x100) that i want to have scrolling across the screen at different speeds. and my original solution is not working out. Originally, I placed them all in a HorizontalScrollView, and made a runnable that used setPadding to adjust the position of the ImageViews within the scrollView. This works, however, the background that is supposed to remain mostly stationary on the screen, shakes back and forth as you scroll, and lags behind the scroll location significantly. It's choppy and it looks bad.
Is there any other way that I can move images across the screen to achieve the desired effect?
(could I perhaps use a frame layout, and set an ontouchlistener? then how would you move the layout across the screen?)
I set up a layout so that the images protrude off of the right of the screen correctly, but I can't seem to move them off of the left of the screen (setpadding(-50,0,0,0) does not work)
Thanks in advance!
I solved this by using relative layouts within a frame layout. I set an ontouchlistener for the frame layout and used the scrollTo method for each image with a modifying coefficient. I had not previously noticed the scrollTo and scrollBy methods of the layout.

overlay imageview without pushing layouts down

a picture is worth a thousand words, so my question should basically be self-explanatory with the attached image: How to get rightmost screen instead of the center screen?
turns out i cannot attach images directly yet, so i have to link to it right now:
How to get rightmost screen instead of the center screen?
just to add, i realise that it is not really possible to have the framelayout NOT expand as shown in screen 2b, but my question remains as to how to achieve such an overlay without pushing the Other layouts down i.e. the bottom part of the imageview would be on top of the top right part of the other layouts
perhaps you could have the image you are dynamically adding be outside the frame layout. ie have a relative layout contain both framelayouts and the imageview – jkhouw1 1 hour ago

Categories

Resources