I have rotated a webview by 90 degrees but now the rotated webview is not taking up the full height. The rotated height seems the old width. The web content still fit in. I have inherited from a webview and overridden the onDraw method
canvas.Translate(0, this.Height);
canvas.Rotate(-90);
canvas.ClipRect(0, 0, this.Width, this.Height, Region.Op.Replace);
base.OnDraw(canvas);
Might be a silly solution but just in case...
Did you try using ="fill_parent" in your axml file?
Related
I have an image thats a particular height and width and its designed in such a way where its content is meant to be displayed at a minimum height, and as the height increases more of the image is allowed to be seen (meant to clip at the frame). This is because we wanted to serve up one image, but depending on device size, the frame can get display as much of the photo necessary.
My question is whats the best way to manage the content mode of the UIImageView to allow for this as well as how should the imageview constraints should be managed. Any advice? My original thought was to have the content mode be 'center' and use a combination of greater and less than height constraints to achieve the height part.
The red rect shows the uiimageview frame at its small screen size (iPhone SE), green is at normal size (iPhone) and orange is for plus devices.
Perhaps the community has a better solve for this?
I'm stuck with something I can't figure out...
My app lets the user zoom/pan a thumbnail image, via a UIScrollView. Then it needs to take the changes the user made in the scrollview and apply them to the same image at a much higher resolution (ie. generate a high-res UIImage that looks the same as the zoomed/panned low-res thumbnail the user touched).
I can see that the scrollview has a zoomscale and contentOffset which I can reuse, but I really can't see how to apply this to my UIImage.
All help much appreciated, thanks!
The zoom scale,contentOffset and frame of the UIScrollView will present a sub rectangle of the thumbnail.
Rescale that rectangle proportionally against the higher res version of your image.
e.g
Your scroller has bounds of 100px x 100px
Your thumbnail is 100px x 100px and is zoomed at 4x with a content offset of (x:100,y:100). You will see a sub rectangle of frame (x:25,y:25,w:25,h:25) against the original thumbnail inside the 100x100 window of the scroller i.e blurry. The width and height comes from the scrollers frame.
Once you flip in a high res image of 1000px x 1000px you are going to want to present the same chunk of the image except now you present (x:250,y:250,w:250,h:250) by setting the zoom to 0.4. contentOffset remains the same.
Note that the zoom of 1x and zero offset which would present the whole thumbnail image is a zoom of 0.1x and zero offset against the higher res.
BUT
You are overthinking the issue. Your container UIImageView does all the work for you. Once you reach your target zoom point simply load the higher res image into the imageView (myImageView.image = hiresImage ) and it will "just work" assuming your contentMode is set to Scale To Fill (UIViewContentModeScaleToFill) or Aspect Fill . The low res image will be replaced by the high res version in exactly the right position.
I am developing a universal app for iOS-7. this particular question is specific to iPad only. I want to place an image as background of root view of a View Controller i.e. the image should fill the whole screen. The 1x image has size:768x1024. This works for Portrait orientations as non-retina resolution of iPad is also 768x1024 in portrait. In Landscape however the image does not fit. I have tried using ScaleToFit but since aspect ratio of image is not preserved I can not use ScaleToFit(their are things in image which look odd when not scaled proportionally in both axis). AspectFill resizing seems most suitable for my need, but their is a small problem. As defined in Apple Documentation "The content is resized to completely fill the bounds rectangle, while still preserving the aspect of the content. The content is centered in the axis it exceeds.". I do not want the content to be centered in axis in which it exceeds, I want it to be aligned to top/left edge.
So basically I want two things:
Aspect Fill
The content remains aligned on the Left/Top edge.
Is it possible to achieve this. Any code-snippet will be great.
Thanks
You will have to subclass the View Controller's view and manually scale and align.
Look at the code snippets in THIS answer.
Adjust imageViewXOrigin and imageViewYOrigin to align however you want.
Really the only way to get around the content fill mode is to have two different images, one for each orientation. I'd suggest changing the image in the view controllers willAnimateToOrientation: method so that you can put the image changes inside UIKit's animation block.
I am trying to display rotated text. The UILabel is added as a subview on a UIImageView. The UIImageView has a transform created via say CGAffineTransformMakeRotation(M_PI/4.0). The text of the UILabel renders fairly blurry cf. the title label (in the screenshot, the blue background 'What's ...').
Do you know how I can manage to make the rotated text render clearly?
I've already tried using an integral-based frame (which matters little since it'll be rotated), a non-clear background color, and setting the label to opaque=YES. Still blurry.
Thanks!
The problem is that your label is rendered in half pixel either in the origin of the frame or the rotation. Check the frame origin after rotation, or try to rotate it by M_PI/4.1 (4.2, 4.3, 4.4, 4.5 - even test values like 4.05 4.15..) until it renders normally. Also check the frame of the UILabel in the UIImageView, could be added at half pixel origin for ex. {0.5, 0.5} or something..
how do i get the width and height of the entire screen in XNA?
Empirically I've found that in XNA 4.0 I need to use
GraphicsDevice.Viewport.Width
GraphicsDevice.Viewport.Height
when running windowed mode, as I find
GraphicsDevice.DisplayMode.Width
GraphicsDevice.DisplayMode.Height
gives me the resolution of the entire screen.
Hopefully this helps someone else out.
This seems to be it (just googled for "xna screen width height" myself):
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
GraphicsDevice.Viewport.Bounds - this returns Rectangle2D and it has parameters Width and Height.