How to customize grid ratio in graphview? - android

I have used GraphView 3.0 library for my ECG analysis project on Android. I cant find any option to customize grids ratio or you can say step size for x and y axis.
If I need to edit the source code then also let me know how am I supposed to edit it and which function can be edited for this purpose?

Do you mean the number of horizontal and vertical labels?
You can set them by using these getGridLabelRenderer methods:
graph.getGridLabelRenderer().setNumHorizontalLabels(int numHorizontalLabels);
graph.getGridLabelRenderer().setNumVerticalLabels(int numVerticalLabels);

Related

Lottie Animation not fit screen height on Android device

I'm using Lottie animation but the animation area(height) only reach half of screen even my LottieAnimationView use 0dp to match parent. I'm not sure is this an animate JSON issue, in JSON width is 768 & height is 1500 and I use pixel 6 which is dp 412 x 915 to test. What I want is coins are able to drop full screen, so I tried use scale y but I found the coin shape will transform, plz help, thx.
Lottie version : com.airbnb.android:lottie:5.2.0
The animation file I use the link :
https://lottiefiles.com/134069-coin-rain
The configs for LottieAnimationView
The animation looks like below, the coins only drop half height of my screen.
I have created demo using your code and yes it is because of json file other wise your code is perfect ..
so you just need to change json file
you can use this json file as mentioned below
https://lottiefiles.com/117802-coin-drop
i have tried to create demo using above json file and it is working fine but it is too fast by default so you need to manage speed as per your requirement .
You can control speed using app:lottie_speed="0.5"
i hope it will help you

How to set major and minor grid lines using Androidplot?

I’m trying to implement the following chart using Androidplot, and I’m wondering how to set the major and minor grids as shown in the picture with Androidplot? Is it using setLinesPerRangeLabel to achieve it? I’m new to Androidplot so some sample code will be of great help, thanks!
Try playing around with setRangeStep() and setLinesPerRangeLabel() (use setDomainStep() & setLinesPerDomainLabel() for domain)
For the step I use StepMode.SUBDIVIDE. When the setLinesPer[Range/Domain]Label is high enough you should start to see the thicker graph lines.

iOS) How to set image's size and coordinate as the same as android

I'm developing ios app for a service that already has android application.
I have psd files and png files corresponding android one.
But I don't know how to set image's size and coordinate as the same as android....
Is there a way to follow android's ratio constructively?
I'm just setting imageview by eye measurement...
By eye measurement, I calculated ratio, size(width,height) and coordinate...
I want to make images set as the same as the android's one.
I'm just using 'aspect to fit', that makes this problem less heavy but not perfect
Calculating everything manually will be horrible when you want to support multiple devices of different screen size. Use constraints if you want to scale the UIImageView to a certain ratio of another view.
Please refer to the auto layout guide at https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html

Android UI based on top and left property

I was working with Android UI in Eclipse and found it to be bit hectic. Designing layout using layout managers is bit time consuming. So i was wondering whether it is possible to specify the position of the UI elements based on (x,y) system i.e top and left property which is widely used in Visual Studio IDE for VB,C# etc ?
Positioning element based on top and left property would provide much flexibility.
How would that be flexible? Yes, doing layout correctly takes time, but if you do it right, it will scale properly to any screen size. If you're using X/Y coordinates, you will be hardcoding to a specific screen size, which is an especially bad idea on Android (as there are a multitude of screen sizes available).
If you need x, y positioning, you can use a FrameLayout with foregroundGravity set to top|left, and use layout_marginLeft for the x value, and layout_marginTop for the y value.
You can use AbsoluteLayout and suppress deprecation warnings in your code, but think of how will it look on different screen sizes?
I would advise to use RelativeLayout in your case.
As far as I know, there is no built-in layout that is based on (x, y) coordinates. You might be able to find 3rd party libraries that can do this for you. However, I'm skeptical that they will provide satisfactory results. Remember that Android is deployed on a wide variety of devices which include a range of different screen sizes and resolutions. This means that you can make the UI look pretty on one device using specific coordinates but it won't look very good on other devices.
Personally, I edit my UI layouts directly in the XML files. I find that this provides me better control than using the Eclipse UI editor. You still have to learn how the layout managers themselves work.
Android tries to ensure that your layout components are arranged nicely so that they:
don't overlap with each other
don't go off the screen space
look similar on different screen sizes
etc
It gives you nice XML Attributes to help you arrange your layout. I would recommend you use RelativeLayout for this application, because it allows you to put your layout components in positions RELATIVE to each other.
Some XML attributes you can specify are given here: Android Reference, RelativeLayout.LayoutParams

How to draw a dynamic graph?

I have to draw a dynamic graph of data from a database in android
Any example code regarding this will be appreciated.
I like GraphViz for generating graphs as .gif files.
So...many...graph questions...
Read here: https://stackoverflow.com/questions/5156740/im-looking-for-fancy-charts-library-for-android/5157576#5157576
TeeChart beta is public: http://steema.com/entry/60
Can heavily recommend TeeChart, it's a great library. Been using it for a while now. Since I haven't put this anywhere yet, here's a bit of my "how-to" document:
TeeChart info:
Disable 3D: chart.getAspect().setView3D(false);
Disable Legend: chart.getLegend().setVisible(false);
Disable footer: chart.getFooter().setVisible(false);
Disable header: chart.getHeader().setVisible(false);
SOLVED - How to set marks to data value instead of cylinder number?
For a Bar data-set: bar.getMarks().setStyle(MarksStyle.VALUE);
SOLVED - How to move the marks closer to the chart rectangle?
bar.getMarks().setArrowLength(5); - or negative values to put them on top of the bar
SOLVED - Different styles:
bar.setBarStyle(BarStyle.RECTANGLE);
SOLVED - How do I put a heavier color reference (in terms of readability) on the legend? Thicker (higher) line, not wider
chart.getLegend().setColorWidth(100); makes it wider, but not thicker or anything
chart.getLegend().setFontSeriesColor(true); helps with the issue by also coloring the text
line.getLinePen().setWidth(5); works, but it will change the width of the line as well.
No legend callback yet.
SOLVED - How do I make the lines thicker in a graph?
line.getLinePen().setWidth(5); works, but it will change the width of the Legend as well.
SOLVED - How do I change the color of labels on axes?
chart.getAxes().getLeft().getLabels().getFont().setColor(Color.WHITE);
chart.getAxes().getBottom().getLabels().getFont().setColor(Color.WHITE);
SOLVED WORKAROUND - How do I set the background color of the chart itself? Tried so far (the TChart methods that take a Color from the TChart Color class, not the View methods) - only managed to make the 'surrounding' area black.
chart.setBackground(Color.BLACK);
chart.getCanvas().setBackColor(Color.BLACK);
chart.getGraphics3D().setBackColor(Color.BLACK);
---> WORKAROUND: Use the setBackground above, then use: chart.getWalls().getBack().setVisible(false); --- setColor() on walls is bugged?
SOLVED - How to choose the bounds of a chart manually?
chart.getAxes().getLeft().setAutomatic(false);
chart.getAxes().getLeft().setMinMax(-2, 2);

Categories

Resources