Creating a View containing irregular sized rectangles (WebViews) - java

I am trying to create an irregular and dynamic view on Android. It consists of many rectangles, which all could have different sizes. The view should be scrollable (displaying more content when you slide your finger up and down on the screen). Every rectangle is a WebView:
Question: What would be the best approach to solve this problem, considering that it should be possible to create dynamic content? Dynamic content means, that data pushed from a server on the device is displayed without any user interaction.
I think with a ListView or a GridView, I can't create elements which are "merged" across ListView and GridView item borders.
Bonuspoints: Do you know of any algorithm which can calculate the layout parameters, such that the screen is filled with tiles, and no spaces are left empty?

Related

Why do my buttons and other elements keep re-arranging in Android Studio?

I'm building a simple app for a game that has labels, textfields and buttons. Every time I try to run the app the elements on the screen keep moving around in the emulator even if they look find in the editor. Picture of layout
I've tried adjusting them by dragging and dropping and experimenting by changing XML. I think I'm missing something, but is positioning elements on the screen the way you want usually this difficult?
If you use lots of views in vertical direction use Linear layout, if more on horizontal use relative layout as you can position elements left-right or center w.r.t each other or parent easily, use a combination of both to get best results.

RecyclerView - how to stack items instead of scroll off screen?

I noticed a cool effect in a game I've been playing and was wondering how to accomplish it in an android application using the RecyclerView (or any other kind of list object in android).
What I'm trying to accomplish: when you scroll the items in the recyclerview, instead of having those items scroll off the screen, I'd like those items to start stacking on top of each other near the edge of the screen. So when you scroll towards the edge, the items start stacking on top of each other. And when you scroll away from the edge towards the middle of the screen, the items start unstacking off of each other.
I'd post an image, but I currently don't have enough reputation, so here is a link to what I'm trying to accomplish:
http://i66.tinypic.com/1z3uubm.gif
Another link in case other one is not available:
http://imgur.com/8GkWKdQ
Any code examples or a general direction would be greatly appreciated! Thanks.

Display grid of images in Android with center of grid layout being empty?

I have a decent amount of images(10 or so) that I need to display in grid form with the center of the layout being empty. Currently I'm adding each image through code but that is becoming time consuming. Every image is using the same onTouchListener class. The center of the layout needs to be empty to accommodate a "container" image view that selected images can be dragged and dropped onto. I thought of using an image adapter but only saw examples that were for a gallery type view in either horizontal or vertical orientation. Is there any way to create a custom class that automatically positions the images in grid form with an empty center that has predetermined dimensions?
If you are using a RecyclerView with GridLayoutManager, then you can get the firstVisisbleItem and lastVisibleItem. This should give you the number of visibleItems with which you can decide the index in the grid where you should not show any item. This would require you to take care of some implementation level details, but the basic logic should be like this only. Hope it helps.

Best Way To Fill Screen With Grid of Images

I'm writing an Android app in java that I want to be able to use across all phone screen sizes and resolutions. I need to create a 4x4 array of images (all square and equal in size). I want the images to expand such that they're width is basically the screen width divided by 4.
I first tried a RelativeLayout, but can't figure it out. I figure TableLayout is probably the way to go, but if I just stretch columns, that won't necessarily stretch the images within the cells, right? I need the images to stretch, not just the columns.
Any ideas?
Take a look at this Layout called GridLayout by Romain Guy. You simply addview() your imageviews .Enjoy

Scaling multiple views in android

I'm creating a board game in android. In my absolute layout, I have a board view, and a tile view. Those two views can overlap each other, since you're placing a tile onto the board by click and drag. I am not using a bitmap drawing for this since I want to handle two separate onTouchEvent for the board and for the tile.
Problem: I want my board view to be able to zoom in and pan. At the same time, I want to tile to know to scale itself. Is there anyway to do this on android? My current solution is to scale the two view separately(which is a lot of work) but I think there should be a better solution than this out there. Or my approach on this is completely off?
Any ideas or help would be appreciated. Thanks!

Categories

Resources