Code Monkey home page Code Monkey logo

spirit-level-custom-view's Introduction

Attributes

<!-- Default value: Color.GREEN-->
<attr name="bubbleColor" format="color" />

<!-- Default value: Color.RED -->
<attr name="bubbleThresholdColor" format="color" />

<!-- Default value: Color.BLACK -->
<attr name="outerCircleStrokeColor" format="color" />

<!-- Default value: Color.BLACK -->
<attr name="innerCircleStrokeColor" format="color" />

<!-- Default value: Color.BLACK -->
<attr name="crossStrokeColor" format="color" />

<!-- Default value: Color:WHITE -->
<attr name="spiritLevelBackgroundColor" format="color" />

<!-- Default value: Color:WHITE -->
<attr name="viewBackgroundColor" format="color" />

<!-- Default value: 25 DP-->
<attr name="bubbleSize" format="float" />

<!-- Default value: 2.5 DP-->
<attr name="outerCircleStrokeWidth" format="float" />

<!-- Default value: 2.5 DP-->
<attr name="innerCircleStrokeWidth" format="float" />

<!-- Default value: 2.5 DP-->
<attr name="crossStrokeWidth" format="float" />

<!-- Default value: 150 -->
<attr name="bubbleInterpolationTimer" format="integer" />

<!-- Default value: true -->
<attr name="withThresholdIndication" format="boolean" />

<!-- Default value: 5 -->
<attr name="thresholdValue" format="float" />

<!-- Default value: true -->
<attr name="withLabel" format="boolean" />

<!-- Default value: 20 DP-->
<attr name="labelTextSize" format="float" />

<!-- Default value: true -->
<attr name="withFlatOnFroundCorrection" format="boolean" />

Usage

The SpiritiLevelView can be added directly to a XML-Layout or progammatically instantiated and added to a parent view

XML-Layout

<com.sample.rgregat.spiritlevelview.view.SpiritLevelView
	android:id="@+id/spiritLevelView"
        android:layout_width="300dp"
        android:layout_height="300dp"
        app:viewBackgroundColor="@color/white"
	app:spiritLevelBackgroundColor="@color/white"
	app:bubbleColor="@color/green500"
	app:bubbleThresholdColor="@color/deeporange500"
	app:crossStrokeColor="@color/gray500"
	app:innerCircleStrokeColor="@color/gray500"
	app:outerCircleStrokeColor="@color/black"
	app:labelColor="@color/black"
	app:bubbleSize="25"
	app:labelTextSize="30"
	app:crossStrokeWidth="2.5"
	app:innerCircleStrokeWidth="2.5"
	app:outerCircleStrokeWidth="5"
	app:thresholdValue="5"
	app:bubbleInterpolationTimer="150"
	app:withLabel="true"
	app:withThresholdIndication="true"
	app:withFlatOnFroundCorrection="true"
        app:layout_constraintBottom_toTopOf="@+id/spiritLevelViewContainer"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

Programmatically

spiritLevelView = SpiritLevelView.Builder(this)
	.viewBackgroundColor(getColor(R.color.white))
    	.spiritLevelBackgroundColor(getColor(R.color.bluegray800))
    	.outerCircleStrokeColor(getColor(R.color.bluegray400))
    	.innerCircleStrokeColor(getColor(R.color.bluegray100))
	.crossStrokeColor(getColor(R.color.bluegray100))
    	.bubbleColor(getColor(R.color.blue500))
    	.bubbleThresholdColor(getColor(R.color.pink500))
    	.labelColor(getColor(R.color.white))
    	.outerCircleStrokeWidth(10f)
    	.innerCircleStrokeWidth(2.5f)
    	.crossStrokeWidth(2.5f)
    	.bubbleSize(10f)
    	.withLabel(true)
    	.labelTextSize(30f)
    	.bubbleInterpolationTimer(150L)
    	.withThresholdIndication(true)
    	.thresholdValue(5f)
    	.withFlatOnGroundCorrection(false)
    	.build()

Result

Screenshot_20230723_173228

spirit-level-custom-view's People

Contributors

rgregat avatar

Watchers

 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.