Setting an Android Tint Color Pre Lollipop - xamarin.forms

I have written an Android custom renderer for a checkbox control.
I set the checkbox disabled color like so
Control.ButtonTintList = ColorStateList.ValueOf(element.DisabledColor.ToAndroid());
where Control is an Android.Widget.CheckBox
This does not work prior to Lollipop and I get an error
CheckboxRenderer.SetDisabledColor (Incident.UserControls.Checkbox
element) Java.Lang.LinkageError: no method with
name='setButtonTintList'
signature='(Landroid/content/res/ColorStateList;)V' in class
Landroid/widget/CompoundButton; no method with
name='setButtonTintList'
signature='(Landroid/content/res/ColorStateList;)V' in class
Landroid/widget/CompoundButton;
I have found some mention of using DrawableCompat to do this but can't figure out how to do it in Xamarin/C#
Any ideas?

using Android.Support.V7.Widget.AppCompactCheckbox instead of Your base Android.Widget.Checkbox might do the trick.
Also to change colour at runtime you could use this:
ViewCompat.SetBackgroundTintList(_YourView , ColorStateList.ValueOf(Color.ParseColor(Resources.GetString(Resource.Color.blueLine))));
Actually, the problem with things not working pre-lollipop is that Android KitKat is obsolete and so are the rest of the versions below so to have features that are new to Android you need to use the Appcompact library for backward compatibility.
Anyways, Goodluck! Happy coding

Related

How to use Toucheffect in Maui. In xamarin forms we can do it using the xamarin toolkit.

This is the shared touch effect files
This is the android platforms specific code
This is where I register the effect and the handler
This is where I used toucheffect nativeanimation property
Some properties are working , for example : the PressedOpacityBackgroundColor. Is there a way to make the native animation property to work
I tried from someone's code from where this issue was mentioned. I implemented as it is but the native animation property isn't working and also some other properties as well.
You can also use the Toutheffect in the MAUI.
You can add the Xamarin.CommunityToolkit.MauiCompat 2.0.2-preview1013 to your project. It is the .NET MAUI Compatible version of Xamarin.CommunityToolkit.

Change not-allowed cursor on drag in React

When I drag an image in react that has draggable set to true, I get not-allowed / no-drop cursor. I can't figure out how to target it with CSS to overwrite. The way I handle the drag is onDragStart then onDragEnd.
Without some reproducable code i just can try a shot in the dark: You have to call at the beginning of your drag handler e.preventDefault();.
I faced the same issue back when I was working on one of my React projects, so I did some research and tested several methods that I found, but nothing worked for me. You see there is a property named DataTransfer.effectAllowed that specifies the effect that is allowed for drag operation, and there is a limitation to this API as you can read here -
https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/effectAllowed
Changing the styles or attaching an eventListener won't work, you have to use a different backend for this. Use react-dnd and react-dnd-touch-backend or react-dnd-html5-backend npm packages as a custom backend.
https://www.npmjs.com/package/react-dnd
https://www.npmjs.com/package/react-dnd-touch-backend
https://www.npmjs.com/package/react-dnd-html5-backend

How to add android attributes like android:id on Xamarin Forms(XAML)?

I've already tried setting android attributes like contentdescription by creating a custom element and setting the attribute on the renderer using the control.
Control.ContentDescription = ((MyEntry)e.NewElement).ContentDescription;
Is there a way to do it on the XAML rather than custom renderer?
Another, how can I set the android:id attribute? I've tried it change it on custom render but I think it's not working.
Sidenote: I'm using a RealWear device which can generats a script which has the UI elements of the page. The UI elements will contain the id attribute if it exists.
Hello and welcome to StackOverflow.
you can't add Android descriptions to xamarin forms elements.
Xamarin forms abstracts the ui to a non-native format (xaml) and converts the abstract definition of an element to a native one. However this happens "under the hood" and therefore you don't have direct access to that from xamarin.forms.
What you could do is, if you really need an element with a set id, you can either find a way to hack in your id using a custom renderer or you create and embed native elements.
For the latter please see the following microsoft article, which is a bit too much to include within this answer: https://msdn.microsoft.com/en-us/magazine/mt790186.aspx

AFrame light change not working

Running
document.querySelector("[light]").components.light.data.color="#A00";
Doesn't do anything, it will add color="#A00" if flushToDOM as an attribute but not change the light.
Changing light="color:#BBB" does work by hand, but what is the best way programmatically to do this now?
Modifying the data object directly isn't supported - you'll want to use setAttribute instead. Example:
var lightEl = document.querySelector('[light]');
lightEl.setAttribute('light', {color: '#a00'});

How can we put image as in the title bar of monodroid screen?

How can we put image as in the title bar of monodroid screen?
I tried using the following code, but it shows error as getwindow() is not a valid function here and I am not able to find a valid equivalent for this in monodroid.
Boolean CustomTitleSupported = RequestWindowFeature (WindowFeatures.CustomTitle);
SetContentView(Resource.Layout.Search);
getwindow().setFeatureInt(WindowFeatures.CustomTitle, Resource.layout.titlebar);
Please help as the android method doesn't seem to work in mono.
In Mono for Android, many cases where Java would have getXXXX/setXXXX methods get translated to properties named XXXX in order to align better with .NET's style. In this care, getWindow() becomes the Window property on Activity.
Following code works for me in Mono-droid.
Here getwindow() is just replaced by window as Greg pointed out.
Boolean CustomTitleSupported = RequestWindowFeature(WindowFeatures.CustomTitle);
SetContentView(Resource.Layout.Search);
if (CustomTitleSupported){
Window.SetFeatureInt(WindowFeatures.CustomTitle, Resource.Layout.titlebar);
};

Resources