Cropping image for portrait and landscape modes - android

In my app user can select his own background image. The problem is, that current crop library only allows single rectangle selection. So when user selects image in portrait and rotates to landscape, image becomes inappropriately cropped. Is there a library that would at least allow to have two visible rectangles (one for portrait, another one for landscape) while selecting the image?

Scissors
https://github.com/lyft/scissors
i am using this library to done cropping for portrait and landscape. if u use this library just sent the ViewPortRatio of CropView for portrait or landscape cropping.
cropView.setViewportRatio(1f / 1.77f); // For Portrait
cropView.setViewportRatio(35f / 19f); // For Landscape

Related

Android - How to make a landscape layout on a fixed portrait screen?

My application's orientation is fixed to portrait due to some functionalities that always in action.
I need to add to the main activity a fragment with a landscape orientation, so it's layout should be portrait, but rotated 90 degrees.
My problem is that a TextView won't fit the screen because it's width is longer than the screen's width. Also, rotating it (or anything else) won't work properly because the rotation is being done after it's being located.
Is there any library that can handle such thing? Or what can I do to handle that problem?

Screen rotation for some not all elements android (Android)

In android when users rotate the screen the entire screen orientation changes to either portrait or landscape, including all the elements on that particular screen. Is there a way to only rotate some elements and keep other elements "locked" in their current orientation? E.g The screen is displaying a button and an image, I want to only allow screen rotations for the button and maintain the same orientation for the image.

Background image changing when it's in landscape mode in MIT App Inventor 2

I uploaded two image for background of my app in MIT App Inventor 2. Once I set a background image for portrait orientation it's ok, but when it's come to landscape same image is showing. I want show different images when device change it's orientation. I have tried in some ways with the screen's logic blocks in the block section. How can I do that?
Create a screen.ScreenOrientationChanged event handler. Add an If, Then, Else block and test if the screen.Width is larger than screen.Height. If so, set your landscape image, if not, set your Portrait image.

Camera Preview code gives as upside down image view android

I am Using a onCLick over a button to capture an image but when we see the preview it is upside down in vertical mode where as when the same preview is seen through horizontal preview renders correctly.
Please let me know what tweaks are necessary to readjust the preview.
You have to take into account, that camera preview image origin is on top right corner if in portait mode, and axes are swapped - and it does not depend on phone orientation. You will have to flip image to display it in portrait mode properly.
take a look at
android.hardware.Camera.setDisplayOrientation
http://developer.android.com/reference/android/hardware/Camera.Parameters.html
and
android.hardware.Camera.Parameters.setRotation
http://developer.android.com/reference/android/hardware/Camera.html

Best way to deal with different Android screen sizes?

We are writing an application for the T-Mobile MyTouch which is an Android based mobile phone. We have images that will be displayed on the default screen portrait mode (320 x 480).
Anticipating that the Android OS will be appearing on Netbooks with default landscape 16 : 9 screen format, what is the best way to handle images that are in a portrait mode format? In other words since you can't rotate the screen on these Netbooks, if you display a portrait mode image on landscape mode screen there will be large blank rectangles on either side of the image.
In terms of image resources within the application, such as is the case with background images, it is a common practice to have different image set for landscape and portrait mode, or even different screen sizes. Surely, you will adapt your layout to it, or at least have a good relative layout.
However, if you are wondering what to do when an image of an unknown size has to be drawn on the screen (e.g. in case of photo album application), it is fine to leave those black rectangles on both sides. Take a look at the behaviour of video player view on the Android Dev Phone 1. It will adapt the video frame height to landscape mode, and it will play the video in the landscape mode whether or not a portrait mode is more suitable.
You deal with it the same way you would deal with the user turning their phone sideways. This is as much a presentation decision as a UI one.
Remember Android supports using alternative layouts for identical Views. If you have a portrait layout e.g. res/layout/gallery.xml, you can create a landscape equivalent in res/layout-land/gallery.xml and Android will automatically load the latter layout file if the Activity is launched in landscape mode.
With the separate layout XML file, you can then arrange your image as you feel best fits the intent of your application (an application displaying medical images may well have different presentation priorities than one displaying a family portrait). You could for example just fill the background with a gradient, or more information that is otherwise hidden in portrait mode. It all depends on what you wish to achieve with your application and the lengths you are willing to go to to account for all possibilities.
But ultimately, provided the user can see the image in it's entirity without needing to flip their netbook on it's side, I imagine they'll be happy :)
You should design your screen with certain anchor points and then position the rest of the views in relation to those anchor points. For example if you have a screen layout which has a banner, a list of items and some buttons under the list then 2 of the ways these can be positioned on the screen:
Place banner at the top. Put the
list under it and then the buttons
under the list.
Place banner at
the top. Place the buttons at the
bottom of the screen and then the
list takes the space between the
banner and the buttons.
Layout 1) will have trouble with different screen sizes and the layout will look odd or may not appear correctly at all. Whereas, 2) gives you a better appearance for most screen sizes.

Categories

Resources