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);
Related
I am trying to customise Seekbar. I need Seekbar like :
How do I add numbered scale to Seekbar as shown in image above?
I have been able to make custom thumb and custom progress drawable simply by using their vectors, in XML, as:
android:thumb="#drawable/custom_seekbar_thumb"
android:progressDrawable="#drawable/custom_seekbar_progress"
android:splitTrack="false"
But I have not been able to use the numbered scale as shown in the image.
Some answers on stack overflow say about how to draw numbers above/below Seekbar, but I couldn't find any information on how to draw the vertical line (|) below each number.
Any help would be appreciated. Thanks!
There is a method setTickMark and xml attribute android:tickMark that can be used to draw vertical lines. But there are two problems. The first one is it is only available in api 24+. The second one is that all the ticks would be the same and in your design they are different.
Unless you find a library that does exactly what you need, your best option is to create a custom view by subclassing/copying SeekBar and customizing the onDraw method.
Has anyone worked closely with the Material Shape Drawable and similar stuff?
The task is to make such a cutout without fail using a gradient and always with a fixed size. The implementation of the picture is not suitable.
And the cutout changes its size depending on whether the panel is closed or not
There are at least some ideas - I'm not sitting for the first day
Hello friend this is called "cradle" of bottomAppBar FloatingActionButton.please refer here to learn more https://medium.com/#vadim.zhukov/easy-way-to-make-curved-bottomnavigationview-with-floatingactionbutton-12b979009e64
I'm using this RoundedCorners library (based on Romain Guy's post) which allows to set both outline border and a rounded rectangular image to an imageView .
I need to add an outer shadow (meaning it's outside of the image being shown) to the image that is shown (say ,to direction south-east) . I've decided that since the border is the larger part of what is shown, I would add the shadow to it instead of to the image, using the next extra code in RoundedDrawable :
mBorderPaint.setShadowLayer(shadowRadius, shadowDx, shadowDy, shadowColor);
Of course, I've also added the fields and populated them with values.
Problem is, the shadow seem to ignore the dx,dy values i've given it, and it's just setting the background to the entire imageView .
I've read here and some people claim that using setShadowLayer on new android API (from 11+) won't work except on texts because it tries to use the GPU , but I've tested it on API10 too and it had the same result.
How could it be? What should I do in order to fix it or use an alternative?
I assume I could add a new paint like the one used for the border, but this would mean I need to change a lot more code that depends on it too (or actually I need to do it anyway? ) . Plus, i might make it a little uglier than what is shown for real shadows.
I'm stepping through "Professional Android 4 Application Development". I'm working on the "ToDoList" example in chapter 4, and to the point of implementing a custom view for the list item. When I run my version of the app, the custom view renders its background color, but the margin line and the text don't appear to render. I've compared my version against the version from the code bundle, and I only see what seem like inconsequential differences, but there must be something subtle that is different.
I obviously want to fix the problem, but something like this is a better lesson on how to figure out what's wrong, but I just don't see it.
I wish I could just zip up the two apps and attach them here, but that doesn't appear to be an option. I did upload my sample app to a shared Google Drive folder, which is included here. I believe I've made it public so that other people can download it.
If someone reports that they can't get to it, I guess I'll just try pasting in the relevant source files here.
...and I only see what seem like inconsequential differences, but
there must be something subtle that is different.
There is a difference that is quite important. In your init method you initialize the float margin variable like this:
margin = myResources.getColor(R.color.notepad_margin);
But, from looking at your code(where you draw the lines) the margin variable seems to be the point at which you draw the vertical lines(in your case margin will be something big and out of the screen). Shouldn't this be:
margin = myResources.getDimension(R.dimen.notepad_margin);
Also, you may want to increase the stroke width to see those lines:
linePaint.setStrokeWidth(3.0f);
Is it possible to have the followings in android font styling.
Leading (the space vertically between lines of text - name comes from the physical piece of lead that used to be used in mechanical printing process to separate lines of text).
Tracking (the horizontal space between each character).
If you have any ideas please share with me.
You can change leading by calling TextView's method setLineSpacing() or changing corresponding XML attributes of TextView in layout (android:lineSpacingExtra or android:lineSpacingMultiplier).
As answered here:
AFAIK, you cannot adjust kerning in TextView. You may be able to adjust kerning if you draw the text on the Canvas yourself using the 2D graphics APIs.
Update: since API 21 there is an option to set kerning/tracking/letter spacing. You can call method setLetterSpacing() or set it in XML with attribute letterSpacing.
For Tracking, check out this answer. It works fine for me.