Hello im writing an android app using the android svg-android.jar. (I think it's the google official library) I'm trying to parse my svg im getting an error. my svg falls on this line :
<stop offset="0.1774" style="stop-color:#EDEDED;stop-opacity:0.2"/>
the error i get is this :
java.lang.NumberFormatException: Invalid int: "EDEDED;stop-opacity:0.2"
in the google code for the project i saw this :
if (gradient != null) {
float offset = getFloatAttr("offset", atts);
String style = getStringAttr("style", atts);
if (style.startsWith("stop-color:#")) {
int color = Integer.parseInt(style.substring("stop-color:#".length()), 16);
color |= 0xFF000000;
gradient.positions.add(offset);
gradient.colors.add(color);
}
}
it seems that google can't handle the style having opacity too.
the svg itself is generated through a program .
my question is this: is there another android library for svg parsing ? i searched and couldn't find .
does the google code site doens't have the latest code ?(google i heard stopped supporting it)
is there another way to give opacity to the stop element which doesn't include the style attribute ?
or most annoying option should I wait for whoever wrote it to fix it ?(commented on google code project site also but the last comment is from 2014 don't know if i get referrenced at all).
help would be appreciated thanks !
There is another to give opacity to the stop element which doesn't include the style attribute, mapped CSS attributes e.g.
<stop offset="0.1774" stop-color="#EDEDED" stop-opacity="0.2"/>
Related
I am having some trouble including a Plot-object (produced by jetbrains.letsPlot() + geomHistogram()) within the activity.xml for a Kotlin Android app. I am familiar with basic activity elements but I don't know which one to use in this case and I can not figure it out using https://github.com/JetBrains/lets-plot.
Any help is very appreciated!
You can use Android' WebView to display a plot.
jetbrains.letsPlot() + geomHistogram() produces a Figure object.
First you will have to convert it to a simple Map object using toSpec() method:
val spec = when (plot) {
is Plot -> plot.toSpec()
else -> (plot as GGBunch).toSpec()
}
Next, you will generate a string (plot HTML representation) using PlotHtmlHelper:
val html = PlotHtmlHelper.getStaticDisplayHtmlForRawSpec(spec)
This way you can generate a web page and load it to WebView. The page should also contain a script tag for loading the Lets-Plot JS library.
The code could look similar to this (but with a newer library version - 2.2.1 currently): https://github.com/JetBrains/lets-plot-kotlin/blob/master/demo/browser/src/main/kotlin/frontendContextDemo/BrowserDemoFrontendContext.kt
If you are using Kotlin/JS you may want to take a look at this example as well: https://github.com/alshan/lets-plot-mini-apps/blob/main/js-ir-frontend-app/src/main/kotlin/Main.kt
I'm new to Xamarin and I'm trying to use the Iconize NuGet package for Xamarin, but I'm not having much luck. At the moment I'm working with a simple Android app. I've installed Iconize per the instructions and, save for an error on the line:
FormsPlugin.Iconize.Droid.IconControls.Init(Resource.Id.toolbar, Resource.Id.tabs);
(the compiler didn't like the Resource.Id.toolbar or Resource.Id.tabs so I removed it) everything compiles and runs. However, when I try to add an IconButton with a Fontawesome image, I get "System.NullReferenceException: Object reference not set to an instance of an object." error that points back to
the line LoadApplication( new App() ); in the MainActivity.cs.
I'm trying to add the IconButton to a grid in code (not XAML) using
grid.Children.Add( new IconButton
{
Image = "fa-info-circle"
}, 3, 2 );
Any ideas on how to make this work? The examples on the Iconize page haven't been very useful and I haven't found any examples on Google.
Okay I finally found something that was useful. I found a clue on this page and some other information on the project issues page on Github.
Ultimately, to get the icon to display I used
grid.Children.Add( new IconButton
{
Text = "fa-info-circle",
}, 3, 2 );
It was the Text property and not the Image property that I should have used.
Hope this helpful to someone else.
thanks for checking my question out!
I'm currently working on a project using Qt C++, which is designed to be multi-platform. I'm a bit of a newcoming to it, so I've been asked to set up the ability to take screenshots from within the menu structure, and I'm having issues with the Android version of the companion app.
As a quick overview, it's a bit of software that send the content of a host PC's screen to our app, and I've been able to take screenshots on the Windows version just fine, using QScreen and QPixmap, like so:
overlaywindow.cpp
{
QPixmap screenSnapData = screenGrab->currentBackground();
}
screenGrabber.cpp
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
}
Unfortunately, Android seems to reject QScreen, and with most suggestions from past Google searches suggesting the now-deprecated QPixmap::grab(), I've gotten a little stuck.
What luck I have had is within the code for the menu itself, and QWidget, but that isn't without issue, of course!
QFile doubleCheckFile("/storage/emulated/0/Pictures/Testing/checking.png");
doubleCheckFile.open(QIODevice::ReadWrite);
QPixmap checkingPixmap = QWidget::grab();
checkingPixmap.save(&doubleCheckFile);
doubleCheckFile.close();
This code does take a screenshot, but only of the button strip currently implemented, and not for the whole screen. I've also taken a 'screenshot' of just a white box with the screen's dimensions by using:
QDesktopWidget dw;
QWidget *screen=dw.screen();
QPixmap checkingPixmap = screen->grab();
Would anyone know of whether there was an alternative to using QScreen to take a screenshot in Android, or whether there's a specific way to get it working as compared to Windows? Or would QWidget be the right track? Any help's greatly appreciated!
as i can read in Qt doc : In your screenGrabber.cpp :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
replace with :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( 0 ); // as 0 is the id of main screen
If you want to take a screenshot of your own widget, you can use the method QWidget::render (Qt Doc):
QPixmap pixmap(widget->size());
widget->render(&pixmap);
If you want to take a screenshot of another app/widget than your app, you should use the Android API...
I'm novice at Xamarin and I'm trying to use ShinobiCharts in Xamarin.Android to show candlestick data on it.
Code from .axml:
<fragment
class="com.shinobicontrols.charts.ChartFragment"
android:id="#+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
This is fragment where should be shown chart.
var chartFragment = (ChartFragment)FragmentManager.FindFragmentById(Resource.Id.chart);
var chart = chartFragment.ShinobiChart;
chart.SetLicenseKey("license_key");
chart.AddXAxis(new DateTimeAxis
{
GesturePanningEnabled = true,
GestureZoomingEnabled = true
});
chart.AddYAxis(new NumberAxis
{
GesturePanningEnabled = true,
GestureZoomingEnabled = true
});
var dataPoints =
quotes.Select(
quoteCandle =>
new MultiValueDataPoint(DateUtils.ConvertToJavaDate(TimeStamp.UnixToDate(quoteCandle.Timestamp)),
(double) quoteCandle.Low, (double) quoteCandle.High,
(double) quoteCandle.Open, (double) quoteCandle.Close)).ToList();
var series = new OHLCSeries { DataAdapter = new SimpleDataAdapter() };
series.DataAdapter.AddAll(dataPoints);
chart.AddSeries(series);
chart.XAxis.Style.GridlineStyle.GridlinesShown = true;
chart.YAxis.Style.GridlineStyle.GridlinesShown = true;
chart.RedrawChart();
This is code of creating ShinobiCharts.
The problem is that added series are not shown in chart. Style changed, but there are no series. What do I do wrong? I hope anyone can help.
Sorry for question, Candlestickes are not available for trial version of ShinobiControls, only for premium version.
As sammyd said, CandlestickSeries are available in the trial version of ShinobiCharts for Android (as are all the other premium features). Have you managed to get the CandlestickChart sample running? The sample is included in the download bundle.
On the face of it your code looks fine (without seeing the rest of it) but there are a couple of things I'd recommend checking:
Have you replaced the string license_key with the trial license key we would have emailed you when you downloaded the bundle? The trial license key is a a really long string of characters and digits.
Is your data coming in as expected and does it make sense (e.g. are your low values less than your open values etc.)?
I'm not sure it'll make much difference, as they're pretty much interchangeable, but you're actually creating an OHLCSeries in code but mention a CandlestickSeries
Have you set the series' style object in a way that would stop it from showing i.e. have you set it to be transparent in colour?
Are you getting an actual error, and if so what message is being logged?
Hopefully the above will help you get your candlestick chart up and running!
Edit:
If you're using the Android Emulator, your AVD needs to have GPU emulation turned on (as we use OpenGL ES 2.0 for rendering the charts). There's more information on using the emulator with OpenGL on the Android developer site.
Disclaimer: I work for ShinobiControls
I'm trying to set a DropDown Background Color for a autocompleteTextView, because the standart Values seem to be different during different Android Versions. For example, everything works fine starting with android 3.2, but previous Versions seem to not accept the android:textColor="#color/black" in the xml, cause it is not working for me. Android 2.3 for example just shows the items in the list and the ones I picked in white, which isn't working for me, cause the background is white too. So I decided to change the background Color determing on the android version using this:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB){
// Do something for Honeycomb and above versions
//everything is right
} else{
// do something for phones running an SDK before froyo
box_Kurs.setDropDownBackgroundResource(Color.BLUE);
box_Teacher.setDropDownBackgroundResource(Color.BLUE);
}
But when I start my app it crashes and shows resource not found exception:
11-19 15:40:17.225: E/AndroidRuntime(450): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shr.khg/com.shr.khg.AddActivity}: android.content.res.Resources$NotFoundException: Resource ID #0xff0000ff
What am I doing wrong? I alread cleaned my project since that what other people suggested. Or is there any easier way to deal with my issue?
Thank you!
The problem is that the setDropDownBackgroundResource() is expecting the id of the Color resource Drawable, not an int that defines a Color. If you look at the Exception you can see that Android is trying to find a component with id #0xff0000ff, this is the hex code for a completely opaque blue which is the value of Color.BLUE
Replce these two lines:
box_Kurs.setDropDownBackgroundResource(Color.parseColor("#0000ff"));
box_Teacher.setDropDownBackgroundResource(Color.parseColor("#0000ff"));