I'm making a scrollable view that contains images and edittexts below each image. The images shown below do not have the edittexts for simplicity. As a image is centered, it needs to "grow" and the image leaving needs to "shrink".
I'd like the images to resize as they become centered. I know how to calculate the sizes and positions in the view of each image as a function of scrollX. I have not tried to implement this, but I'd like to hear some opinions before trying to do this.
What is the best way to efficiently do this?
Will it be computationally expensive to have 10 images (that will be the max) loaded and being constantly resized as the view scrolls? Will this be choppy?
Ideas:
- Calculate each image size and position upon the scrollX changing. Resize and reposition each image.
- Keep track of only the images that will be growing/shrinking as they are centered/leaving the center. Resize and reposition these as the view
Thoughts? What do you think would be the best implementation of this? Thanks!
Related
So what i have is a RelativeLayout that is a grid with 25x25 elements what i am trying to do is make a crossword puzzle. I use the https://github.com/natario1/ZoomLayout so i can zoom in and out of the puzzle. The cells are pretty simple they are only a TextView with background a png image that is set in the xml. There is no lag if this stays like this but if i try to use CardView or try to do a elevation of the cell so there is a shadow it starts to lag(interestingly it lags only on a real device not on emulator).
So i was wondering am i approaching the problem in a wrong way?
Should i just remove the grid and try to draw on the canvas?
Is there a way to optimize the shadows so they don't cause lag?
Should i cache the background image of the TextView in a bitmap and pass it in the TextView so i maybe get a faster loading (i don't know how this works since the image is loaded in the xml so i assume it uses a cached image)?
Should i just use some other way to do the game?
Any suggestion will be appreciated
My recommendation would be to draw the grid on the canvas and when the user taps the grid, calculate the cell at that location and add a new View (CardView with whatever properties you want) at that point. Your performance will be drastically better but it does require you do do some Math.
How to make a offer up kind of grid UI (please look the image 1), it has three same sized columns and height differs according to image size. i have implemented the view with the 3 linear layouts and a scroll view. but it's not very supportive when it comes to memory management. Can i make the view with grid view (since height is different)? or should i use any other method? or is it ok to use scrollview to load about 100 images at a time?
enter image description hereI have a custom view and the user can draw rectangles(I used canvas). I would make the size of custom view bigger than the size of the screen. So, the user can draw not only in the size of screen. I tried ScrollView and NestedScrollView but they are not helpful to solve my problem.
As far as I could understand from this question is you want to make a canvas where someone can draw some pictures. So you need a bigger canvas to that user can drag the positions to left-right, up and down. If I understood correctly, then I would say, you might think of a different work-around instead of looking for a view bigger than the screen size.
You can think of an simple ImageView which will be auto zoomed-in and if the user clicks twice it'll zoom-out. The user can drag the positions of the ImageView whenever he wants.
Here's an SO answer about how you can implement the zoom in and out in an ImageView. Hope this will help to solve your problem.
I have an Android Gallery setup on a layout with both the width and height set to Fill_Parent. This works great for smaller screens, but as the display size grows into the tablet sizes, the Gallery stretches to a layout that is taller than it is wide. At this point, there are no more side images on it - that is, just the main selected image is visible. I want to have at least a small amount of the side images visible so the user knows the view is scrollable.
Does anybody know how I can do this?
Is it possible to maintain an aspect ratio while still using fill_parent? Is it possible to set the Gallery view to show a certain amount of the side images? etc?
Thanks!
The Gallery class is pretty limited and personally I tend not to use it. Have you considered using a ViewPager instead?
AFAIK, If you are using
android.widget.Gallery
then the implement a custom adapter to the view, and set a layout wrapped to each items inside the gallery view. If you still don't understand what I just said, I would try to generate some reference code.
I would like to have a scrollable image gallery that takes up most of the screen. My images are small icons all of the same size. I can have a lot of images. Once the maximum number of images fills the screen horizontally, they should wrap to the next row. If there are more images than will fit in the vertical direction, then it should be possible to scroll vertically to view additional images. I am not sure what layout controls I should be using to accomplish this. An additional feature (be not a must have), is that the images are equally spaced horizontally with the same amount of margin. Any suggestions? Thank you.
Try a GridView.
Use GridView. Perfectly fits your needs.