I designed a xamarin forms app working practically only on android to implement renderer and other more specific objects, now I have to bring the iOS part to par, the problem arises with the renderers since I have to "translate" the code from android to iOS.
I share below a renderes that I have no idea how to translate a few lines, if you can translate it you would do me a big favor, thanks.
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
{
bottomView.ItemIconTintList = default;
int[][] states = new int[][]
{
new int[]{-Attribute.StateChecked}, // unchecked
new int[]{Attribute.StateChecked}, // checked
};
int[] colors = new int[]{
Xamarin.Forms.Color.FromHex("#0D5EB4").ToAndroid(),
Xamarin.Forms.Color.FromHex("#0D5EB4").ToAndroid(),
};
ColorStateList navigationViewColorStateList = new ColorStateList(states, colors);
//bottomView.ItemIconTintList = navigationViewColorStateList;
bottomView.ItemTextColor = navigationViewColorStateList;
This is my class for Android
Related
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFeed : MonoBehaviour {
// Use this for initialization
public Renderer rend;
void Start () {
WebCamDevice[] devices = WebCamTexture.devices;
// for debugging purposes, prints available devices to the console
for(int i = 0; i < devices.Length; i++)
{
print("Webcam available: " + devices[i].name);
}
Renderer rend = this.GetComponentInChildren<Renderer>();
// assuming the first available WebCam is desired
WebCamTexture tex = new WebCamTexture(devices[0].name);
rend.material.mainTexture = tex;
//rend.material.SetTextureScale("tex", new Vector2(1.2f, 1.2f));
tex.Play();
}
// Update is called once per frame
void Update () {
}
}
I use the above code to render camera feed on a plane. The code works fine but I see zoomed feed(around 1.2x) when deployed to iPad. How can I get the normal feed. Or How do I zoom out the camera feed
According to https://answers.unity.com/questions/1421387/webcamtexture-zoomed-in-on-ipad-pro.html if you insert this code it should scale properly:
rend.material.SetTextureScale("_Texture", new Vector2(1f, 1f))
Furthermore, it seems that you were trying something like this but your vector was off (by 0.2f) though you have commented out that line as well. You could reduce the scale even more though that could make the image just smaller if the camera couldn't support that zoomout :).
I have scenario in my project where I need to perform zoom in action Android Mobile web using Appium automation. I have used the following method.
try {
Dimension size = driver.manage().window().getSize();
int x0 = (int) (size.getWidth()*0.5);
int y0 = (int) (size.getHeight()*0.5);
System.out.println(x0+" "+y0);
driver.zoom(100, 500);
reportStep("The Application is zoomed.", "PASS");
} catch (Exception e) {
e.printStackTrace();
reportStep("The Application could not be zoomed.", "FAIL");
}
But this method working fine in Mobile apps and not working in Mobile web.
Are there any specific method or alternate work around to handle the Mobile web zoom?
I am using Appium Java-client version 5.0.4 and Selenium version 3.6.0.
Zoom and Pinch methods are not available in the latest version.
There are not many examples out there without zoom method, but using MultiTouchAction class in conjunction with TouchAction class should work as shown here. Note that using moveTo with WebElement and offset x,y coordinates instead of absolute is advised in that thread.
driver = new AndroidDriver(new URL(nodeURL), capability);
TouchAction touchAction = new TouchAction(driver);
MultiTouchAction multiTouchAction = new MultiTouchAction(driver);
WebElement search = (WebElement) driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"com.google.android.apps.maps:id/search_omnibox_container\")"));
touchAction .tap(search).perform();
int leftX = search.getLocation().getX();
int rightX = search.getSize().getWidth() + leftX;
int upperY = search.getLocation().getY();
int lowerY = search.getSize().getHeight() + upperY;
a1 = touchAction.press(search,x1,y1).waitAction(2000).moveTo(search,x3,y1).release();
a2 = touchAction.press(search,x2,y1).waitAction(2000).moveTo(search,x4,y1).release();
multiTouchAction.add(a1).add(a2).perform();
Also, look here for appium MultiTouch and here for passing offset x,y co-ordinates to moveTo
I want to implement Xamarin forms image zoom property. I did search the internet for quite some time but I didn't find any relevant documentation, can anyone provide me some information on how to implement it in Xamarin Forms?
Currently there is no zoom property for image. You have to use custom renderer to acheive that.
Try using ScaleTo, Itz similar to zoom but not exactly zoom functionality.. Hope it helps...
var img = new Image {
Source = "foo.png",
Scale = .9
};
var stepper = new Stepper {
Minimum = .1,
Maximum = 1,
Increment = .1,
Value = .9,
};
stepper.ValueChanged += async (object sender, ValueChangedEventArgs e) => {
img.ScaleTo(e.NewValue);
};
I had the same need to implement zoom, click, ... on images on Xamarin Forms.
On the forum i find a plugin that define custom renderers for the 3 platforms that can allow you to get coordinates of click on image and then to implement the zoom you want to do.
Here the website of the plugin : http://www.mrgestures.com/
It costs 10euros for every application you develop. Depending on what you need to implement and how many times you will need it it's not expensive at all.
The issue comes with scale property that its scaled to the center of x and y ,
I've implemented this extension no need for extra renderer.
public static Task<bool> ScaleTo(this VisualElement view, double scale, double anchorX, double anchorY, uint length = 250, Easing easing = null)
{
var tcs = new TaskCompletionSource<bool>();
if (easing == null)
{
easing = Easing.Linear;
}
new Animation(
(v) =>
{
view.Scale = scale;
view.AnchorX = anchorX;
view.AnchorY = anchorY;
}, 0, length
).Commit(view, nameof(view), 16, length, easing, finished: (f, a) => tcs.SetResult(a));
return tcs.Task;
}
You can implement pinch to zoom by using a pinch gesture recognizer.
Here is the documentation on pinch to zoom
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/pinch
At the same time if you want to add pan, you can combine the above code with
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/pan
Then you would have a pretty good full screen image viewer in Xamarin.Forms
You can use this library, just install on your .netstandard project and that's it!
You can then use Rg.Plugin.Popup and add the image dynamically by providing the link
xmlns:pinch="clr-namespace:Xamarin.Forms.PinchZoomImage;assembly=Xamarin.Forms.PinchZoomImage"
<pinch:PinchZoom.Content>
<Image Source="xxamarin.jpg" />
</pinch:PinchZoom.Content>
I have a project using Xamarin with MvvmCross. In this project i want to create a QR-Code in a MvvmCross Plugin. I have it working in the Android plugint. However, the iOS plugin creates an corrupted image, which I cannot open after creation.
I use ZXing.Net PCL (Version: 0.14.0.1)
My code:
public byte[] GenerateQrImage(string content, int width, int height)
{
if (string.IsNullOrEmpty(content) || width <= 0 || height <= 0) return null;
var options = new QrCodeEncodingOptions
{
Height = height,
Width = width,
Margin = 0,
PureBarcode = true
};
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = options
};
// Get bytes
return writer.Write(content);
}
The above code returns a byte array which I can save. When I open the application folder on my Mac, I cant open the image (I think its corrupt).
Can anyone tell me, how i can solve this problem? Thanks
After many tests (and also many fails) i found the solution. I took the wrong nuget-package. Just reference to Zxing.Net.Mobile and the qr-image generation works.
At the end it's the same problem described here.
I am wondering how to include debug code inside the XNA? Like console.writeline
Enable the console.
In Visual Studio right-click your project in Solution Explorer. Then click on "Properties" and in the "Application" tab select "Console Application" as your Output-Type.
Don't forget to change it back to "Windows Application" in order to disable the console when you are done debugging.
have you seen the Debug class in the System.Diagnostics namespace? That can send output to the debug console in VS (or an external one like DebugView)
For drawing text there is method spritebatch.DrawString(....) this is how i draw fps count.
class FPS_Counter
{
private SpriteFont spriteFont;
private float FPS = 0f;
private float totalTime;
private float displayFPS;
public FPS_Counter(SpriteBatch batch, ContentManager content)
{
this.totalTime = 0f;
this.displayFPS = 0f;
}
public void LoadContent(ContentManager content)
{
this.spriteFont = content.Load<SpriteFont>("Fonts/FPSSpriteFont");
}
public void DrawFpsCount(GameTime gTime,SpriteBatch batch)
{
float elapsed = (float)gTime.ElapsedGameTime.TotalMilliseconds;
totalTime += elapsed;
if (totalTime >= 1000)
{
displayFPS = FPS;
FPS = 0;
totalTime = 0;
}
FPS++;
batch.DrawString(this.spriteFont, this.displayFPS.ToString() + " FPS", new Vector2(10f, 10f), Color.White);
}
You might want to take a look at our toolset Gearset. It is a set of tools that can help you with that. It has a dedicated window that shows you a pretty view of the output, organized by color, and provides filtering which can become quite useful when there's a lot of output.
Gearset also provides you with other tools like curve editing and real-time inspection of your objects. There's a free version and a paid version (the difference being a single feature which is unavailable in the free version). Hope it helps.
You can always use Debug.WriteLine and read your Debug messages window. Or use the tracepoints.