Giter Club home page Giter Club logo

android-water-gauge's Introduction

Android Water Gauge

A customizable water gauge to display devices orientation

Android Arsenal

alt text

Using the Android Water Gauge

Add it into and .xml file like:

<com.mhmt.library.view.OrientationFeedbackView
      android:layout_width="50dp"
      android:layout_height="300dp"
      android:layout_alignParentStart="true"
      android:layout_centerVertical="true"
      app:gauge_plane="YZ"
      app:gauge_orientation="vertical"
      app:gauge_range="60"
      app:gauge_threshold="20.0"
      app:gauge_ball_accept_color="@android:color/holo_green_dark"
      app:gauge_show_degrees="true"
      app:gauge_degree_display_text_color="@android:color/holo_red_light"
  />

If you want to be notified when the threshold is passed in either way, add a OnAcceptabilityChangedListener to your water gauge like :

waterGauge.setOnAcceptabilityChangedListener(new OnAcceptabilityChangedListener() {
      @Override public void acceptabilityChanged(final OrientationFeedbackView view, final boolean acceptable) {
        // do something!
      }
    });

It's highy customizable, give it a go with the following attributes

attribute Explanation
gauge_plane The device plane this water gauge responds to
gauge_orientation The orientation of the water gauge, can be horizontal or vertical
gauge_range The amount of angle this gauge will span, in degrees. This is the total of two sides
gauge_threshold After what displacement from the origin the gauge will change color
gauge_ball_accept_color The color of the ball in it's natural state
gauge_ball_reject_color The color of the ball when it passes the threshold
gauge_line_width The width of the line in the middle of the water gauge
gauge_line_color The color of the line in the middle of the water gauge
gauge_background_color The background color of the water gauge
gauge_corner_radio How much the corners of the water gauge curve
gauge_show_degrees Whether the current orientation should be shown, in degrees
gauge_degree_display_text_color The color of the degree text

Adding to your App

This library is available through jitpack central. Just add the following to your app-level gradle file:

dependencies {
        compile 'com.github.mhmtk:androidwatergauge:0.6.0'
}

and, the following to your top-level gradle file if you don't already have it:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

For adding it using other ways, check out https://jitpack.io/#mhmtk/androidwatergauge/0.6.0

Feel free to leave any comments/suggestions!

android-water-gauge's People

Contributors

mhmtk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.