i am using a Matrice 300 RTK and a H20 camera, this camera have 5184×3888 resolution for phtos that is 4:3 ratio and the video have 16:9 ratio, so in my app i need to show the camera, in mode video all ist ok but when i change to mode photo whit you CameraControlsWidget the image that show the dron are so stretch horizontally, them when i use the DJIPilot this effect dont show, in this app the borders of image are in black for show a correct aspect ratio of 4:3 i put the code of mi xml if you need anything more for make a solution say me and thank in advance.
<TextureView
android:id="#+id/camera_live_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
/>
<dji.ux.widget.FPVOverlayWidget
android:id="#+id/camera_live_view_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
Related
Im trying to display an admob ad which completely covers the width of screen (like SMART_BANNER), and 90dp constant height.
using this code, i can set the height to 90dp, but how can i make the ad width fill the width?
AdSize adSize = new AdSize(deviceSpecificWidth, 90);
According to this, these are the standard sizes of SMART_BANNER
Screen width x 32|50|90
can i force the smart banner to only use 90dp height in every device?
I would suggest to use the newly introduced AdMob Adaptive Banners. They don't require adjustments on your side and they utilize all the width available and keeping the aspect ratio (which was a problem before).
Embed them into a FrameLayout like following
<FrameLayout
android:id="#+id/adFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center|bottom" />
Alright, this seems like it can be a very confusing question but I'm going to try anyway.
I am developing an application right now, and the only thing that you should know is that there are two drawables in this application.
Both drawables have the same exact width. There is a background drawable that obviously goes in the background of the XML. And then theres an ImageView of a simple line. This line is a drawable aswell.
On some devices/emulators, the line is not the full width of its resolution. Despite the fact that both drawables have the same exact width. And both are viewed in the same portrait mode.
Is there any fix to this? Basically this line moves upwards and represents something important, but I can't have it be a different size than the background. I really don't fully understand why the background with a width of 600, and a line with a width of 600 isn't the same size on some devices. Despite putting both drawables in the Drawable folder, and not one for the different resolutions. I currently do not have any screenshots, I will make some if need be, but I hope someone knows why this problem is bugging me and if I am doing something wrong. Can I perhaps tell the application that its resolution must be 800x600, so that all devices that are capable of showing that many pixels, will do so? If this is possible, how do I do this? I hope someone is able to help
a newbie out :)
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:gravity="top"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:src="#drawable/line" />
</RelativeLayout>
Try setting the scaleType of the imageview to fitXY.
android:scaleType="fitXY"
I would like to scale my application layout to the screen size.
When I run it on a 4 inch emulator (but I don't display the actual screen size, so it looks larger)
It looks like this,
However when I run it on a larger emulator with the actual screen size, it looks like this,
My layout.xml is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="false"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
Followed by the images and buttons.
The width and height of all images and buttons are,
android:layout_width="wrap_content"
android:layout_height="wrap_content"
I guess what I am asking is how to scale the layout to fit the size of the screen?
Like the way it fits the screen when the screen size is 4inch in emu but is not displaying to actual screen size.
As I want to be able to use the application on larger tablets.
You can use different layouts for different screen sizes.
And by the way...are these images from an emulator??
I hope you are not using "scale to actual size" while running your emulators...
Difference in pixel and resolution may also lead to this
In your relative layout, do this
android:layout_width="match_parent"
android:layout_height="match_parent"
This will make the layout fill the screen.
EDIT:
For the ImageView, use
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
This would stretch the image to fit the width (hopefully).
The connect ImageView is a tricky one. Not sure what will work for that. You'll need to experiment with the scaleType attribute.
For the buttons, increase the text size and set the layout_width as wrap_content. The buttons will get bigger.
I have created a 6x7 board for a connect 4 game.
All the empty cells are image buttons.
When in portrait mode the board looks like this.
However, when I change orientation to landscape it looks like this.
The layout for one of the empty cells (Which I repeat) is
<ImageView
android:id="#+id/r6c4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/arrow4"
android:layout_centerHorizontal="true"
android:contentDescription="#string/emptyBox"
android:src="#drawable/empty"
android:visibility="gone"/>
I am very new to android, can anyone point out how I may be able to resize the images to fit the landscape screen?
Thanks
I have a simple widget containing an ImageView. I'd like to fetch an image from the web and display it in the ImageView while maintaining the aspect ratio.
Here's the layout definition for the widget:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/quality_image"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="#+id/widget_icon"
android:layout_marginBottom="#dimen/widget_spacing"
android:scaleType="fitXY" />
</LinearLayout>
..and this is the image in question:
I'd like the image to always fit the height of the ImageView. This bit has been easy. If the width of the ImageView is less than that of the image, I don't mind if the image gets cropped horizontally as long as the aspect ratio is maintained. I've set the maximum size of the widget to never be more than the size of the image so we don't have to worry about cases when the height of the ImageView is more than the image.
I'm terribly lost with this and have begin wondering if this is even possible since there doesn't seem to be way to access the widget dimensions. Sometimes the most trivial things bog you down.
Assuming that part of this question is to maximize the height of the widget given the number of cells it occupies (per the fill_parent in the LinearLayout and given you’re open to cropping the width). I’ll ignore the cropping part of the question and provide an example that maintains a specified aspect ratio.
The best way I’ve found to maintain aspect ratio on an AppWidget at maximum height is to create an XML Drawable of a fixed aspect ratio, scale it down to the max height of the widget, and then tie the sides of the ImageView to it using a RelativeLayout. Example:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget_layout"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/aspectratio"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:src="#drawable/frame_aspect"
android:scaleType="fitCenter" >
</ImageView>
<ImageView
android:id="#+id/quality_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignLeft=”#id/aspectratio”
android:layout_alignRight=”#id/aspectratio”
android:layout_alignTop=”#id/aspectratio”
android:layout_alignBottom=”#id/aspectratio”
android:scaleType="fitCenter" >
</RelativeLayout>
Here is the layout for the drawable (frame_aspect.xml) that specifies the aspect ratio. Note - it is important that this shape is larger than your widget will ever be. The built in scaleType’s do a good job scaling down, but are not so good at scaling up.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape = "rectangle">
<size
android:width="1000px"
android:height="500px"/>
</shape>
Now that you have a widget with quality_image scaled to the maximum height for a given aspect ratio, you can play with the scaleType on the ImageView to determine what if any cropping is best.