I have a custom view that is scaling to 200% when the user clicks on it.
Now I want to prevent some controls/views in that custom view from beeing scaled.
Is there some way to do this?
After further investigating I think there is no way to programmatically freeze a view as described. As a dirty workaround you can put the view that should not be scaled in another container that is positioned over the scaled view.
Related
I have a RelativeLayout and I want to save its content to Bitmap. There are tonns of solutions here but no one suits for my task.
The main difficult is that view has, lets say, 700x900 px size. I want to get a screenshot of that view as the size would be 1000x1000. I cannot just make a screenshot with getDrawingCache() and scale it because views inside RelativeLayout will be shrinked/stretched.
I think that I need to resize view itself, make a Bitmap from it, and resize it back. But! If I resize a view it will be bigger than screen and getDrawingCache() works only for visible part of the view. I cannot put my into ScrollView to workaround such behaviour.
Any help is appreciated.
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'm trying to resize a viewGroup from the right to the left. Inside my viewgroup I have some images. I tried to put all the scaletype values. The problem is that my images are getting scaled. I want them not too move.
What I want is basically resize my view and not see the image being scaled. Like if the view was hide by something going in front of it. I'm doing an animation so the goal is suposed to simulate a hidding motion. Like a truck passing in front of a car, the car is not scaled, just hide. The car is my view and the truck the width. I don't want to hide it with another view in front of it by making a translation. If possible i don't want to touch to my images, I already put the centerCrop value, but if you have a solution with it, share it please lol.
I don't have the code under my hands right now so I can't show you, but if you have any idea, thanks to share ;).
I'm trying to build a point-and-click adventure for Android without using any pre-written engine, but I'm stuck in a really crucial point!
I have a HorizontalScrollView bigger than the screen, so the user can scroll left and right in portrait mode to search around rooms, now what I need is to insert items that the player can use inside this View.
I'm trying to use static ImageView, but I'm really confused on how to insert Views in an absolute position inside the HorizontalScrollView. All I know is that Android manages Views location relative to other views (align on top, next to, bottom of), but what I use if I need to position a View in a specified position using specific coordinates without worrying that the image will be misplaced in a different screen size for other Android devices?
I really am confused on how position views in Android :/
Consider creating your own view instead of abusing HSV.
Custom views, doDraw() method, canvas and even gesture detection is not that hard.
Here is a link that will help you with basics, simple viewport implementation for android with scrolling via key events: http://sonnygill.net/android/android-viewport/
what I use if I need to position a View in a specified position using specific coordinates without worrying that the image will be misplaced in a different screen size for other Android devices
Actually, that's exactly the reason ViewGroup (layouts) were created.
You should choose the right layout based on your requirements.
If you do want to position the views by yourself, you can create your own custom ViewGroup by extending one of the view group classes and override the onLayout(...) and onMeasure(...) methods which are used to position and measure child views (in you case, probably the ImageViews) respectively.
You can use this example of FlowLayout as a reference on how you can write your own custom ViewGroup.
Please note that if your content is bigger than the screen as you mentioned, the HorizontalScrollView should be a parent of a single child (which should be the ViewGroup containing your images).
i have to take something like a screenshot in my android application. It is not a screenshot, it should be a "viewshot". It is about to render the complete content view on a bitmap.
I have found the solution to render the content view of the activity on a bitmap, but if the content view is bigger than the activity, it is only the visible part which gets drawn onto the bitmap.
Does anybody have a solution for this, or some ideas what to google?
Thanks
The content view is never "bigger than the activity", by definition.
The content view may be scrollable, but most scrollable things are either AdapterViews or use a tile mechanism (e.g., MapView), none of which are rendered until they are scrolled into a visible position. There is no stock way to make a "viewshot" of things that have not been rendered. You are welcome to create your own AdapterViewShotter that iterates over the items in the Adapter, captures each to a Canvas, and stitches the lot together into a huge image.