Android 仪表板 DashboardView

DashboardView

Sample 下载
Github 项目地址 (好用的话请给个 star 支持一下

这是一个Android仪表板View,就像汽车等机械仪表板一样。 支持许多自定义样式。

预览图


使用

Gradle ​

修改项目 build.gradle,增加下面代码:

    dependencies {
        compile 'com.ayst.dbv:dashboardview:1.5.1'
    }

Java

    public class MainActivity extends AppCompatActivity {
    
        private DashboardView mDashboardView;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            mDashboardView = (DashboardView) findViewById(R.id.dashboardview_1);
            mDashboardView.setValue(50); // Set value
            mDashboardView.resetValue(50); // Set value and clear maximum and minimum
        }
    }

XML

如果决定使用DashboardView作为视图,则可以在xml布局中定义它,如下所示:

   

NOTE:

  • dbv_firstColor - First range color
  • dbv_secondColor - Second range color
  • dbv_thirdColor - Third range color
  • dbv_max - Max value
  • dbv_min - Min value
  • dbv_section - Value range (mMax-mMin) equal parts
  • dbv_portion - One section equal parts
  • dbv_lineWidth - Line stroke width
  • dbv_colorWidth - Color progress stroke width
  • dbv_colorPadding - Color progress padding
  • dbv_longScaleLength - Length of long scale
  • dbv_shortScaleLength - Length of short scale
  • dbv_startAngle - Starting angle, 0 degrees at 3 o'clock
  • dbv_sweepAngle - Draw the angle, the difference from the start angle to the end
  • dbv_value - Value
  • dbv_showValueText - Whether to display value text
  • dbv_showPointerRange - Whether to display pointer range
  • dbv_firstRange - This is a percentage, starting with the minimum value, showing first color within this percentage
  • dbv_secondRange - This is a percentage, starting with the first range, showing second color within this percentage
  • dbv_headerText - The header text
  • dbv_headerTextColor - Header text color
  • dbv_pointerColor - Pointer color
  • dbv_minPointerColor - Min Pointer color
  • dbv_maxPointerColor - Max Pointer color
  • dbv_scaleColor - Scale color
  • dbv_scaleTextSize - Scale text size

你可能感兴趣的:(Android 仪表板 DashboardView)