Android線性羅盤視圖:CompassView
該庫提供了一個完全可定制的線性羅盤視圖。
用法
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 } });
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!