I face issue to apply vectordrawable at my imageView and Edittext
here is my tries to fix the issue
First I am using Xamarin.Android.Support.Vector.Drawable Version 23.4.0
Second I add AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
in onCreate of my Application
public class MyApplication : Application
{
public MyApplication(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip)
{
Log.Debug("App", "I am in oncreate application");
}
public override void OnCreate()
{
base.OnCreate();
AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
}
}
*Third * usingAppCompatActivity
to make sure my activity used AppCompatImageView instead of normal ImageView
and try set drawable manually but it return with null (I dont know why this happen )
[Activity( Label = "Activity1", Theme = "@style/AppTheme")]
public class Activity1 : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.test);
ImageView testImage = FindViewById<ImageView>(Resource.Id.imageViewTest);
Drawable drawable = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_arrow_back_white_24dp, null);
testImage.SetImageDrawable(drawable);
}
}
Fourth in my project .csproj I add build tools version 23.0.3
<AndroidSdkBuildToolsVersion>23.0.3</AndroidSdkBuildToolsVersion>
here is my full file content
?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AndroidSdkBuildToolsVersion>23.0.3</AndroidSdkBuildToolsVersion>
<AndroidDesignerPreferredDevice>Nexus 4</AndroidDesignerPreferredDevice>
<SelectedDevice>Nexus_5_API_21_x86</SelectedDevice>
<AndroidDesignerPreferredTheme>Theme.DeviceDefault</AndroidDesignerPreferredTheme>
</PropertyGroup>
</Project>
Fifth I reference my vector image app:srcCompat
but it still not working any one could help me fix this issue
I fix first half of my issue Simplly update to
make sure you reference your vector images by this way
app:srcCompat
related to EditText Image I think you cant set it from xml you need to use it via code here is the method
in my case I used leftdrawable so my method look like
hope this help any one face same issue