0

I am using a custom gauge: ChariotGauge

The problem is I am not able to display the needle and only my gauge gets shown.

I have used the gaugeBuilder.java from the library and in my `mainactivity onCreate() instance I have added the below code:

minValue = 0; maxValue = 100; gauge1.setTotalNotches(80);
gauge1.setIncrementPerLargeNotch(10); 
gauge1.setIncrementPerSmallNotch(2); 
gauge1.setScaleMinValue(minValue); 
gauge1.setScaleMaxValue(maxValue); 
gauge1.setScaleCenterValue(50, true); 
gauge1.setUnitTitle("Pressure"); 
gauge1.setAbsoluteNumbers(true); 
gauge1.setValue(minValue);`

The Screenshot for problem

Can anyone help me out in displaying the needle. I just need to set the needle, not continuous.

karan
  • 8,637
  • 3
  • 41
  • 78
pavan
  • 11
  • 3
  • 2
    it is always good to share the code so that other users can check and point out the issue and fix. – Rajen Raiyarela Dec 25 '15 at 05:44
  • I have used the gaugeBuilder.java from the library and in my mainactivity oncreate instance i have added the below code: minValue = 0; maxValue = 100; gauge1.setTotalNotches(80); gauge1.setIncrementPerLargeNotch(10); gauge1.setIncrementPerSmallNotch(2); gauge1.setScaleMinValue(minValue); gauge1.setScaleMaxValue(maxValue); gauge1.setScaleCenterValue(50, true); gauge1.setUnitTitle("Pressure"); gauge1.setAbsoluteNumbers(true); gauge1.setValue(minValue); – pavan Dec 25 '15 at 05:45

2 Answers2

0

Try this it will help

Add this in gradle

compile 'com.cardiomood.android:android-widgets:0.1.1'

layout xml-file

<com.cardiomood.android.controls.gauge.SpeedometerGauge
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:padding="8dp"
    android:id="@+id/speedometer" />

ConfigureSpeedoMeters

private SpeedometerGauge speedometer;

  // Customize SpeedometerGauge
  speedometer = (SpeedometerGauge) v.findViewById(R.id.speedometer);

  // Add label converter
  speedometer.setLabelConverter(new SpeedometerView.LabelConverter() {
      @Override
      public String getLabelFor(double progress, double maxProgress) {
          return String.valueOf((int) Math.round(progress));
      }
  });

  // configure value range and ticks
  speedometer.setMaxSpeed(300);
  speedometer.setMajorTickStep(30);
  speedometer.setMinorTicks(2);

  // Configure value range colors
  speedometer.addColoredRange(30, 140, Color.GREEN);
  speedometer.addColoredRange(140, 180, Color.YELLOW);
  speedometer.addColoredRange(180, 400, Color.RED);

For more see this

Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
  • I have already used this gauge. It is taking too much space which doesnt display properly on resize and moreover it is not a circle gauge. Thanks for the reply anyways. – pavan Dec 25 '15 at 05:55
0

Thanks all...I got the solution from Canvas not displaying all drawn parts in Custom View?

I had to sent the following to gauge :

gauge1.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
Community
  • 1
  • 1
pavan
  • 11
  • 3