Make a view fall of the screen - android

I have a RelativeLayout where I add and position Views (Buttons, TextViews) by changing their top and left margins. I can position them half outside the layout on the top and left side, but when I try to move them half outside the layout on the bottom or right side, they change shape to stay inside the layout.
How can I make the views fall outside the screen instead of resize them self?
Giving them a width does not solve it.

You can't do it using RelativeLayout, which always need to fit the screen size.
You can use ScrollView wich extends a FrameLayout and can be larger then the screen.
Regards.

Related

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.

Move an element in relative layout to absolute edge of the screen

Is it possible to move a button or any other element in relative layout to the absolute edge of the sreen? If I drag a certain element to the edge of the layout, eclipse will automatically place it a few dp away from the edge. It'll basically just create a small space between a button and the end of the creen. Is it possible to bypass that?
I know buttons aren't meant to be that close to the edge of the screen anyway, but I need it for a certain thing.
The normal button has a little padding by default, because the buttons backgroundimage is a 9-patch image with padding left, right and on bottom. That's why you see the space between button and screen.
To solve this you can use a custom button. For example change the backgroundimage of button like this android:background="#drawable/image".

Android: Drag View outside screen

I have an activity where users can drag and drop around some buttons.
All my draggable views are inside a RelativeLayout and to drag them around I change their top and left margins.
Everything works perfect, except that when I drag the views close to the right and bottom edge of the screen, they shrink instead of being drawn outside the screen.
Is there any way for having the same behaviour on the all edges of the screen (currently only works fine on the top and left edge).
I guess I can have a left and top negative margin. But when I have left margin > screen width or top margin > screen height the images shrink.
To implement custom positioning of views inside a ViewGroup the best way is to implement your custom ViewGroup overriding onLayout().
It is not that difficult and I explained how to do it here. (the question is newer and has more visibility)
Edit:
You might also want to look into the Drag and Drop Api here. Thanks to Zainodis for the comment.

Horizontal Scroll View and a gap with overlapping content

After some issues, I now have a working horizontal scroller, it uses a linear layout, with various image views inside, the problem is, I want some of the image views to overlap each other, I achieve this by using
myImageView.setX(-100);
The problem is, there is a big blank space at the end of the scroller, as if all of the image views widths have been taken into account but as they have been moved back a bit, an empty space has been left.
Is there a way to use a relative layout with a scroller? Or a way to manually decrease the width of the scroller so my overlapping content fits?

Android: Stretching ImageView with background

I have a landscape layout that features a vertical LinearLayout of buttons on the left side of the screen and a user-defined picture on the right of the screen. The design I'm working from calls for a double-stroke border around it, which I implemented by creating a rectangular shape background with the border being the outer color and the background of the shape being the inner color. I then just put some padding around the picture, and you get the double-stroke border. The problem is expanding the picture to fill the space in the layout. I don't know the dimensions of the picture, since it is user defined, and I'd like it to expand to exactly fill either dimension while preserving the aspect ratio. Setting fill_parent for both width and height does that, but it also expands the background all the way to completely fill the cell, resulting in a sort of letter boxing effect. Is there any way, short of just adjusting the size of the view after layout, of getting this to only expand the view as much as necessary?
I never got this to work properly, and just ended up adjusting my layout to a different arrangement.

Categories

Resources