Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143929 | Apr 10,2019 08:34 PM UTC | Nov 16,2020 10:48 AM UTC | Xamarin.Android | 24 |
![]() |
Tags: SfChart |
Hi Bardi,There is no direct approach to add custom layout as android widgetReference link:Maybe we can try to add custom layout as image by below link.Regards,Bharathi.
var data = new Hour_Range(Application.Context);
Bitmap bitmap = getBitmapFromView(data.chart);
widgetView.SetImageViewBitmap(Resource.Id.chart, bitmap);
public Bitmap getBitmapFromView(View view)
{
Bitmap bitmap = Bitmap.CreateBitmap(view.Width, view.Height, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bitmap);
view.Draw(canvas);
return bitmap;
}
{Java.Lang.IllegalArgumentException: width and height must be > 0
at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <…}
data.chart.Measure(400, 400);
data.chart.Layout(0, 0, 400,400);
Bitmap bitmap = Bitmap.CreateBitmap(400,400, Bitmap.Config.Argb8888);
. . .
chart.DrawingCacheEnabled = true;
. . .
Android.Graphics.Bitmap bitmap = null;
using (bitmap = chart.DrawingCache)
{
. . .
try
{
//Update bitmap to widget
}
}
finally
{
chart.DrawingCacheEnabled = false;
}
. . .
}
|
Android.Graphics.Bitmap bitmap = null;
MainActivity._chart.DrawingCacheEnabled = true;
using (bitmap = MainActivity._chart.DrawingCache)
{
try
{
//bitmap = getBitmapFromView(_chart);
widgetView.SetImageViewBitmap(playground.Droid.Resource.Id.chart, bitmap);
}
. . .
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.