/CompassView-Android

A custom compass which scale according to the value of the parameter

Primary LanguageJavaMIT LicenseMIT

CompassView

A custom compass that shows the direction of a vector ahd can be scaled according to it's magnitude.

It is similar to arrows shown in the google weather card.

Issues:

This custom view doesn't support resizing to more than 22dp x 22dp and doesn't support xml attributes yet.

How to use:

adding compass to xml

 <com.example.hp.sunshine.Compass
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/wind_compass"/>

Find View in Java

Compass compass = (Compass) view.findViewById(R.id.wind_compass);

By default the compass is 22dp x 22dp which is it's full scale size and is at 0 degrees to North

compass.setAngle(windAngle); // @param: integer angle (N = 0, E = 90, S = 180, W = 270)
compass.setScale(windSpeed); // @param: float scale: e.g 0.45f (max upto 1.0f) otherwise the arrow will become bigger than the view bounds

set direction

LICENSE:

Issued under Apache license 2.0.

How to contribute:

  • fork this repo to your profile.

  • clone it locally using the following command.

    > git clone https://github.com/YOUR_USERNAME_HERE/CompassView

  • Edit the CompassView.java file as you wish.

  • Run and Enjoy :-)