CompassView

Android Arsenal

Compass view for Android.

This library provides a fully customizable linear compass view.

image

Latest Version

Download

How to use

Configuring your project dependencies

Add the library dependency to your build.gradle file.

dependencies {
    ...
    compile 'com.redinput.compassview:compassview:1.0'
}

Adding and Customizing the View

You can declare a CompassView just like that:

<com.redinput.compassview.CompassView
    android:id="@+id/compass"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:backgroundColor="#000000"
    app:showMarker="true"
    app:markerColor="#FF0000"
    app:lineColor="#FFFFFF"
    app:textColor="#FFFFFF"
    app:textSize="15sp"
    app:degrees="0"
    app:rangeDegrees="180.0" />

Property values shown above are the defaults of the CompassView and it can be omitted for brevity.

Also, you can set all that properties with Java.

CompassView compass = (CompassView) findViewById(R.id.compass);

compass.setDegrees(57);
compass.setBackgroundColor(Color.YELLOW);
compass.setLineColor(Color.RED);
compass.setMarkerColor(Color.BLACK);
compass.setTextColor(Color.WHITE);
compass.setShowMarker(false);
compass.setTextSize(37);
compass.setRangeDegrees(270);

Another feature is that you can move the 'CompassView' dragging the view horizontally and even you can attach it a 'OnCompassDragListener' to observe the changes on the degrees value.

compass.setOnCompassDragListener(new CompassView.OnCompassDragListener() {
    @Override
    public void onCompassDragListener(float degrees) {
        // Do what you want with the degrees
    }
});

License

Copyright 2014 RedInput

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


CompassView

机器人阿森纳

适用于Android的指南针视图。

此库提供完全可定制的线性罗盘视图。

最新版本

下载 数据规范-SRC

如何使用

配置项目依赖关系

将库依赖关系添加到build.gradle文件。

dependencies {
    ...
    compile 'com.redinput.compassview:compassview:1.0'
}

添加和自定义视图

您可以像这样声明一个 CompassView

<com.redinput.compassview.CompassView
    android:id="@+id/compass"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:backgroundColor="#000000"
    app:showMarker="true"
    app:markerColor="#FF0000"
    app:lineColor="#FFFFFF"
    app:textColor="#FFFFFF"
    app:textSize="15sp"
    app:degrees="0"
    app:rangeDegrees="180.0" />

上面显示的属性值是CompassView的默认值,为简洁起见可以省略。

此外,您可以使用Java设置所有属性。

CompassView compass = (CompassView) findViewById(R.id.compass);

compass.setDegrees(57); compass.setBackgroundColor(Color.YELLOW); compass.setLineColor(Color.RED); compass.setMarkerColor(Color.BLACK); compass.setTextColor(Color.WHITE); compass.setShowMarker(false); compass.setTextSize(37); compass.setRangeDegrees(270);

另一个特点是您可以移动CompassView水平拖动视图,即使您可以附加一个OnCompassDragListener来观察度值的变化。

compass.setOnCompassDragListener(new CompassView.OnCompassDragListener() {
    @Override
    public void onCompassDragListener(float degrees) {
        // Do what you want with the degrees
    }
});

许可证

Copyright 2014 RedInput

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.




相关问题推荐