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?
Related
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.
I want to represent a DataBase output to a GridView, the deal is that I want this GridView scroll horizontally and vertically. The reason for that is that I may have a table that has a number of columns that will not fit on screen, So Horizontal scrolling is necessary.
Now for vertical scrolling: I may have a big DataBase (with 100 entries and more...) So I do want it to scroll vertically as well and use the View recycling mechanism to populate the GridView (for the Vertical Scrolling, no View recycling is needed for the Horizontal Scrolling).
I have already stumbled on this solution:
https://gist.github.com/codeswimmer/869685
But I have few problems with this:
1. It uses a deprecate Gallary View.
2. I think this changes the vertical scrolling to a horizontal one but doesn't allow both of them.
Is this even possible?
Any direction on this topic would be really appreciated.
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.
Is there a way to connect items within a GridView with lines / arrows preferably in the background?
I have a dynamic amount of items (buttons) within a GridView and have to connect certain buttons with others depending on data of a database.
The GridView will most likely be larger than the screen so the view containing the lines/arrows will have to scroll with the GridView simultaneously.
[question]: Android: network relationship graph describes my problem in a more detailed way.
If it were me, I would think to define a layout to be used as the "background" object of your gridview. The layout would be a single relative layout with a custom view that fills parent in both dimensions.
Within this custom view, I would then override the "onDraw" method and all appropriate constructors to perform your arrow drawing on the singular canvas that should be the exact size now of your gridview!
This is where I would think to begin.
Also look here:
Draw background of custom View from .png file on Android
as it shows how to set the backgroundDrawable of a view. If you implement a custom view as drawable, then you should be able to create a new one and send it into your grid view's background drawable.
To make it scroll along with your actual grid data, you may need to play around a bit with the size of the gridview being the full size of the DataSet you are displaying, and containing that within other scrollviews to get this accomplished.
I do have a gridview in an app of mine, that I implemented a horizontal scrollview (as I have buttons at the top allowing me to sort by any of the columns and want those always to be visible, and the gridview to vertically scroll underneath). This creates the overall width of the gridview for me as it simply follows the parent width which wraps the content of the linear layout defining the button set at the top. The gridview then auto scrolls in the vertical direction, leaving the higher level horizontal scroller to perform in the horizontal direction. For you, you may need to have a vertical scroller within a horizontal scroller, and allow your gridview to be full size (i.e. larger than the content view area) and allow the outer scrollers to perform the scrolling for you. This may be the only way to ensure that your background drawable view is the proper size to the table you are trying to display!!!
I'm working on the controls for a game, and require part of the control panel (gray in the figure below) to change dynamically, either showing a single canvas (left) or 5 buttons (right). The border between the lower-row views should always be positioned at exactly the same x-position as the border between the buttons on the upper row, as shown. At the same time, all twelve upper buttons should be scaled and distributed evenly.
I've considered several approaches, but as of yet none do all of what I want:
Using two LinearLayouts, one for each row of controls: reliably aligning the borders seems to be impossible, and replacing part of the layout is difficult at best.
Using a TableLayout: again, replacing a portion of the layout is difficult.
Using a RelativeLayout: resizing and aligning buttons independently of the screen size doesn't seem possible
Any suggestions for an alternative method, or on how to make one of the above approaches work? It would also be nice if there were some way to animate the change of views, i.e. sliding in the buttons from the left over the canvas. Thanks!
Interesting, I've done this several weeks ago. What I did is to make use of this property of View object: "Visibility". So that means at a fixed position, I can set any View to display on to, not depending on any type of Layout, it can be Visibility.GONE, Visibility.VISIBLE or Visibility.INVISIBLE.
In my app, I used RelativeLayout to set relative position to the right side TextView.
Give it a try :)
In order to close this question: I have solved the problem by writing a custom layout class that places and sizes the child views without heeding the measured size of the children. Effectively this gives me the behavior of a linear layout with layout weights, but is more deterministic with border placement.
A ViewAnimator is used to switch between the Canvas and the Buttons.