We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Position Center

How do I centralize digital gauge ?

Attachment: quest.jpg_86038e7d.zip

1 Reply

PA Paul Anderson S Syncfusion Team May 22, 2015 12:00 PM UTC

Hi,

Thank you for using Syncfusion products.

We would like to inform that the gauge can be added in any layout and it can be positioned using ‘setGravity’ method available in layouts.By default the gauge will have the size of the available space. So it is needed to set the control size based on the CharacterHeight of the control. For further customizing the positions setX and setY methods can be used for modifying its X and Y positions. Please refer the below code snippet for positioning through layout.

[Code Snippet]
SfDigitalGauge digitalGauge1 = new SfDigitalGauge(context);
digitalGauge1.setCharacterHeight(25);

float cheight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT,(float) digitalGauge1.getCharacterHeight() , context.getResources().getDisplayMetrics());

float cwidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT,(float)( 8*digitalGauge1.getCharacterWidth()+8*digitalGauge1.getCharactersSpacing()) , context.getResources().getDisplayMetrics());

digitalGauge1.setLayoutParams(new LinearLayout.LayoutParams((int)cwidth, (int) cheight));
digitalGauge1.setValue("VALUE");
LinearLayout gaugeLayout = new LinearLayout(context);
gaugeLayout.setGravity(Gravity.CENTER);
gaugeLayout.addView(digitalGauge1);
setContentView(gaugeLayout);

Please let us know if you need any further assistance on this.

Regards,
Paul Anderson S

Loader.
Up arrow icon