tags:

views:

71

answers:

4

Is it possible to create a view that is bigger than the screen?

I need a view that has a bigger width then the screen of the device. I use this view in a rotation animation. During the rotation the parts that were not on the screen before animating the view will become visible.

Is there a way to achieve this effect with the android framework?

Update

I tried to set my parent layout much bigger then the screen and it is working. This will make somethings a little bit uncomfortable but it could work. The next problem now is that my layout still starts at the left side of the screen. I can't think of a method to make the layout to expand itself to the left and the right of the screen.

A: 

You can use ViewSwitcher to handle that. Used with Animation and a OnGestureListener looks pretty good.

WarrenFaith
I dont want to switch views I want a view that is rotating as the user rotates his phone and will show different parts of it depending on the phone orientation.
Janusz
Than I recommend what Paresh Mayani has suggested or a SurfaceView implementation...
WarrenFaith
A: 

HorizontalScrollView:

http://developer.android.com/reference/android/widget/HorizontalScrollView.html

Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display.

fredley
I don't think that animating a scroll view is a good idea.
Janusz
+1  A: 
Is it possible to create a view that is bigger then screen? 

Why not, you can define the Layout_Width and Layout_height with pixels(or dip) as much as you wants:

android:layout_width="10000px"
android:layout_height="20000px"
PM - Paresh Mayani
Yes but the parent layout of the view will clip the view if it gets bigger then they are.
Janusz
But you can use the padding of a layout with negative values that allows you to "scroll" inside.
WarrenFaith
Okay I was not very specific I updated my question, this could actually work but I have another problem now.
Janusz
A: 

Ok I got an answer. It is not very nice because it uses a deprecated View class but it works at least on my current testing screen resolution other resolutions are tested tomorrow.

I wrapped the view that I wanted to expand beyond the screen in an absolute layout like this:

  <ImageView
     android:id="@+id/content"
     android:layout_width="600dip"
     android:layout_height="420dip"
     android:scaleType="centerCrop"
     android:layout_x="-200dip"
     android:layout_y="60dip"
     android:src="@color/testcolor" />

The -200 x coordinate makes the view stick 200dip out of the left side of the screen. If I'm animating the view those parts that are outside the screen will gradually become visible.

Janusz