I need to hide the domain values in a linegraph. Could someone please help me?
plot0.setDomainBoundaries(0, windowsize, BoundaryMode.FIXED);
plot0.addSeries(series0, formatter);
plot0.setDomainStepMode(XYStepMode.INCREMENT_BY_VAL);
plot0.setDrawRangeOriginEnabled(true);
plot0.setTicksPerRangeLabel(5);
plot0.getLegendWidget().setVisible(false);
plot0.getGraphWidget().getBackgroundPaint().setColor(Color.BLACK);
plot0.getGraphWidget().getGridBackgroundPaint().setColor(Color.BLACK);
plot0.setTicksPerDomainLabel(5);
plot0.centerOnRangeOrigin(0);
plot0.setRangeBottomMax(-20);
plot0.setRangeTopMin(20);
plot0.setRangeLowerBoundary(-75, BoundaryMode.FIXED);
plot0.setRangeUpperBoundary(75, BoundaryMode.FIXED);
plot0.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 25);
plot0.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 240);
UPDATE:-
Library version
compile 'com.androidplot:androidplot-core:0.9.7'
I have modified the XML with as below. But the changes are not reflecting unless I modify it inside the code.
<com.androidplot.xy.XYPlotZoomPan
android:id="#+id/dynamicXYPlot0"
androidplot.renderMode="use_background_thread"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="20dp"
android:background="#android:color/black"
ap:backgroundColor="#000000"
ap:borderColor="#000000"
ap:label="Lead I"
ap:domainTickLabelTextColor="#00000000"
ap:domainOriginTickLabelTextColor="#00000000"
ap:gridPaddingBottom="1dp"
ap:labelTextSize="10sp" />
I'd suggest trying to do it in XML by adding these params:
ap:domainTickLabelTextColor="#00000000"
ap:domainOriginTickLabelTextColor="#00000000"
ap:gridPaddingBottom="1dp"
This basically sets the tick label color to be completely transparent and removes the extra padding needed to display those labels below the grid.
Before:
After:
Got the solution. Adding these 2 lines worked.
plot0.getGraphWidget().getDomainTickLabelPaint().setColor(Color.TRANSPARENT);
plot0.getGraphWidget().getDomainOriginTickLabelPaint().setColor(Color.TRANSPARENT);
Related
Hey anyone know why this (see in the picture) happens?
It's happens for Xiaomi MiA1, while on Nokia 7.1 works fine.
My xml view layout
FrameLayout - root
ScrollView
RelativeLayout
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/profile.EMAIL"
android:theme="#style/TextInputLayoutTheme"
android:margin="16dp"
android:paddingBottom="8dp"
app:layout_constraintTop_toBottomOf="#+id/phone_wrapper"
>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:textSize="16sp"
android:textColor="#color/darkTextColor"
android:imeOptions="actionDone"
tools:text="Email"
/>
</com.google.android.material.textfield.TextInputLayout>
I think that putting TextInputLayoutTheme is not relevant here, since I only manipulate with view's colors
The error message text gets cut off if you are setting the error on a TextInputLayout more than once.
So every time you are setting TextInputLayout error message text, just set it to null first.
textInputLayout.setError(null);
textInputLayout.setErrorEnabled(false);
textInputLayout.setError("Error Message");
Layout Inspector shows that even if there is some space for the error it doesn't draw view in all of it. Everything there is in LinearLayouts (and one simple FrameLayout) so there is no way something would overlap it, paddings are set to 0, there is no code changing height or something suspicious in the implementation, so I don't know what might be a reason of such behaviour.
Although I've found some solution which works. You need to find in TextInputLayout a view holding error (with id textinput_error) and add some small padding to it. I've done it by extending TextInputLayout and adding such code into init.
val errorTV = findViewById<TextView>(R.id.textinput_error)
errorTV.updatePadding(top = 4)
There is already issue on issue tracker - https://issuetracker.google.com/issues/116747167 so lets hope Google will fix it some day.
I resolved issue by saving and restore LayoutParams:
final ViewGroup.LayoutParams params = textInputLayout.getLayoutParams();
textInputLayout.setError(errorMessage);
textInputLayout.setLayoutParams(params);
I resolved issue by increasing size of error font to 14sp (orginal is 12sp)
<com.google.android.material.textfield.TextInputLayout
[...]
app:errorTextAppearance="#style/MyProfile.Error">
<style name="MyProfile.Error" parent="TextAppearance.Design.Error">
<item name="android:textSize">14sp</item>
</style>
Although as Shabbir Dhangot said I may be that setting TIL.setErrorEnabled(true) may help for some else.
As some have already pointed out, this is a known bug. See https://issuetracker.google.com/issues/116747167
I solved this by doing something like this (note that below code is Kotlin, so != works on Strings):
if(myInputLayout.error != error){
myInputLayout.error = error
}
I know it is not the best solution, but you can add a \n to the beginning of your error message.
For example, if your error is Error, just change it to \nError.
If you want to change the size of the \n you can use:
String newLine = "\n";
String errorMessage = "Error";
SpannableString spannableErrorMessage = new SpannableString(newLine + errorMessage );
spannableName.setSpan(new TextAppearanceSpan(activity, R.style.my_style),0,a.length(), 0);
spannableName.setSpan(new RelativeSizeSpan(2.0f), a.length(), a.length() + 1, 0);
You can use this Kotlin extension:
/**
* Fix a bug with [TextInputLayout] that cut the error text when setting the same text twice.
*/
fun TextInputLayout.setFixedError(errorTxt: CharSequence?) {
if (error != errorTxt) {
error = errorTxt
}
}
Usage:
yourTextInput.setFixedError("Your error text")
I was using the library version 0.9.7 and everythng was working as expected. When I moved to 0.9.8, the range tick labels and domain tick lables became invisible. I have not done any other changes other than the library upgrade.
Please find my xml
<com.androidplot.xy.XYPlotZoomPan
android:id="#+id/dynamicXYPlot0"
androidPlot.graphWidget.marginBottom="10dp"
androidPlot.graphWidget.marginLeft="10dp"
androidPlot.graphWidget.marginRight="10dp"
androidPlot.graphWidget.marginTop="10dp"
androidplot.renderMode="use_background_thread"
android:layout_width="match_parent"
android:layout_height="150dp"
ap:backgroundColor="#00000000"
ap:borderColor="#00000000"
ap:label="Lead I "
ap:labelTextColor="#757575"
ap:labelTextSize="15sp" />
And this is my plot initialization.
private void initializePlot(XYPlotZoomPan plot, int tick, SimpleXYSeries series) {
plot.setDomainBoundaries(0, windowsize, BoundaryMode.FIXED);
plot.addSeries(series, formatter);
plot.setDrawRangeOriginEnabled(true);
plot.setTicksPerRangeLabel(Constants.RANGE_TICKS);
plot.setTicksPerDomainLabel(Constants.DOMAIN_TICKS);
plot.getGraphWidget().getRangeOriginTickLabelPaint().setTextSize(20);
plot.getGraphWidget().getRangeTickLabelPaint().setTextSize(20);
plot.getGraphWidget().getDomainOriginTickLabelPaint().setTextSize(20);
plot.getGraphWidget().getDomainTickLabelPaint().setTextSize(20);
plot.getLegendWidget().setVisible(false);
plot.setBackgroundColor(Color.WHITE);
plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
plot.getGraphWidget().getDomainOriginLinePaint().setColor(dkgrey);
plot.getGraphWidget().getDomainOriginTickLabelPaint().setColor(dkgrey);
plot.getGraphWidget().getRangeOriginTickLabelPaint().setColor(dkgrey);
plot.getGraphWidget().getRangeOriginLinePaint().setColor(dkgrey);
plot.getTitleWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0,
YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP);
plot.centerOnRangeOrigin(0);
plot.setRangeBottomMax(-Constants.RANGE_MIN);
plot.setRangeTopMin(Constants.RANGE_MIN);
plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, tick);
plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, Constants.DOMAIN_TICK);
adjustRangewindow();
}
The easiest fix would be to add a style param to your plot's xml:
style="#style/APDefacto.Dark"
On a side note, you can optionally replace of the formatting you're doing in code with xml. Additionally, there now exist formal styleable attrs for these params:
androidPlot.graphWidget.marginBottom="10dp"
androidPlot.graphWidget.marginLeft="10dp"
androidPlot.graphWidget.marginRight="10dp"
androidPlot.graphWidget.marginTop="10dp"
While these will continue to work, they rely on Configurator which is the older way of styling via xml. Replace with:
ap:marginTop="10dp"
ap:marginBottom="10dp"
ap:marginLeft="10dp"
ap:marginRight="10dp"
The full list of styleable attrs available in 0.9.8 can be found here. The documentation for these attrs is sparse at the moment, but should get much better in the upcoming 1.0 release.
I am using CircularFillableLoader and I want to change loader bar color like code
<com.mikhaellopez.circularfillableloaders.CircularFillableLoaders
android:id="#+id/circularFillableLoaders"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/your_logo"
app:cfl_border="true"
app:cfl_border_width="12dp"
app:cfl_progress="80"
app:cfl_wave_amplitude="0.06"
app:cfl_wave_color="#3f51b5" />
JAVA
CircularFillableLoaders circularFillableLoaders = (CircularFillableLoaders)findViewById(R.id.yourCircularFillableLoaders);
// Set Wave and Border Color
circularFillableLoaders.setColor(Color.RED);//Error when add this line
and i try with another code , it still not work.
int color = Color.parseColor("#1F45FC")
i got error message when device loading ? What is wrong with this code
Could you help me?, please
Thank you.
as i got from you it is simple just change app:cfl_wave_color="#3f51b5"
and change #3f51b5 to color code without java code
I am learning Android and the following is part of an assignment.
I need to write some text in an Android layout with the first letter in drop caps, like the following text:
I looked up the web and did not find many answers. Is there a style option or some property that I could use?
At the moment, I am thinking of the following options. Please suggest what is the best way to do such a thing
Use an image for the first letter
Write the first letter separately in a big font.
Any suggestions would be helpful.
You can use a RelativeSizeSpan.
final String someText = "A long time ago in a galaxy far, far away";
final SpannableString ss = new SpannableString(someText);
ss.setSpan(new RelativeSizeSpan(5f), 0, 1, 0);
There's a library written by Novoda in which you can add a DropCap https://github.com/novoda/spikes/tree/master/drop-cap
Here's an image from the demo app:
Please follow GitHub sample app
https://github.com/datanapps/CapTextView
<datanapps.captextview.CapTextView
android:id="#+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:padding="5dp"
app:layout_constraintTop_toBottomOf="#+id/text1"
app:capsDropNumber="2"
app:capFont="#font/eb_garamond_regular"
app:capTextColor="#color/purple_700"
app:capTextSize="#dimen/cap_text_size"
app:bodyTextColor="#color/purple_700"
app:bodyTextSize="#dimen/body_text_size"
app:bodyTextFont="#font/eb_garamond_regular"
/>
Hope it will help
I am currently trying to draw a graph within an Android application. The library I found is called GraphView (http://www.jjoe64.com/p/graphview-library.html). I am currently using version 2, which is available on GitHub.
Drawing graphs works really nicely. The code necessary to get a graph is the following:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Map<String,List<GraphEntry>> graphData = (...)
if (graphData != null) {
List<GraphEntry> entries = graphData.get("temperature");
GraphView.GraphViewData[] data = new GraphView.GraphViewData[entries.size()];
int i = 0;
for (GraphEntry entry : entries) {
data[i++] = new GraphView.GraphViewData(entry.getDate().getTime(), entry.getValue());
}
GraphView.GraphViewSeries graphViewSeries = new GraphView.GraphViewSeries("temperature", 0xffff0000, data);
LineGraphView graphView = new LineGraphView(this, "temperature");
graphView.addSeries(graphViewSeries);
graphView.setShowLegend(true);
LinearLayout graphLayout = (LinearLayout) findViewById(R.id.layout);
graphLayout.addView(graphView);
}
}
This will produce a normal graph. Unfortunately, all kinds of labels are missing. The documentation tells that for the normal use case, one does not have to care about labels, as the library does this automatically. What am I doing wrong? I only get the plain graph, without any labels.
For the completeness, I am adding the graph to a linear layout. The appropriate layout file has the following contents:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="5dp"
android:id="#+id/layout"
android:orientation="vertical"
></LinearLayout>
The GraphEntry class is only a container with a java.util.Date attribute and a double value attribute.
Thank you very much for any help,
Matthias
I switched to another charting engine: AChartEngine. This one works out of the box.
I had the same problem. This can be solved by removing the following line from the manifest file.
android:theme="#style/AppTheme"
I know this is quite vague, but worked for me. I don't the exact reason why this happens. If u guys come across the better solution please do share it.
You should use the latest version from github and include that in your project. This will allow you to set various colours using
graphView.getGraphViewStyle().setGridColor(Color.GREEN);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.YELLOW);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.RED);