This is an Android dashboard View, like a mechanical dashboard such as a car. Support many custom styles.
No more support
Add dependencies in build.gradle of your module:
dependencies {
compile 'com.ayst.dbv:dashboardview:1.5.1'
}
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
}
}
If you decide to use DashboardView as a view, you can define it in your xml layouts like this:
<com.ayst.dashboardview.DashboardView
android:id="@+id/dashboardview_1"
android:layout_width="300dp"
android:layout_height="wrap_content"
app:dbv_firstColor="@color/red"
app:dbv_secondColor="@color/yellow"
app:dbv_thirdColor="@color/green"
app:dbv_max="0"
app:dbv_min="-100"
app:dbv_section="10"
app:dbv_portion="10"
app:dbv_lineWidth="2dp"
app:dbv_colorWidth="10dp"
app:dbv_colorPadding="10dp"
app:dbv_longScaleLength="15dp"
app:dbv_shortScaleLength="10dp"
app:dbv_startAngle="180"
app:dbv_sweepAngle="180"
app:dbv_value="-30"
app:dbv_showValueText="false"
app:dbv_showPointerRange="true"
app:dbv_firstRange="30"
app:dbv_secondRange="20"
app:dbv_headerText="dbm"
app:dbv_headerTextColor="@color/white"
app:dbv_pointerColor="@color/white"
app:dbv_minPointerColor="@color/white_30"
app:dbv_maxPointerColor="@color/white_30"
app:dbv_scaleColor="@color/white"
app:dbv_scaleTextSize="12sp"
/>
NOTE:
dbv_firstColor
- First range colordbv_secondColor
- Second range colordbv_thirdColor
- Third range colordbv_max
- Max valuedbv_min
- Min valuedbv_section
- Value range (mMax-mMin) equal partsdbv_portion
- One section equal partsdbv_lineWidth
- Line stroke widthdbv_colorWidth
- Color progress stroke widthdbv_colorPadding
- Color progress paddingdbv_longScaleLength
- Length of long scaledbv_shortScaleLength
- Length of short scaledbv_startAngle
- Starting angle, 0 degrees at 3 o'clockdbv_sweepAngle
- Draw the angle, the difference from the start angle to the enddbv_value
- Valuedbv_showValueText
- Whether to display value textdbv_showPointerRange
- Whether to display pointer rangedbv_firstRange
- This is a percentage, starting with the minimum value, showing first color within this percentagedbv_secondRange
- This is a percentage, starting with the first range, showing second color within this percentagedbv_headerText
- The header textdbv_headerTextColor
- Header text colordbv_pointerColor
- Pointer colordbv_minPointerColor
- Min Pointer colordbv_maxPointerColor
- Max Pointer colordbv_scaleColor
- Scale colordbv_scaleTextSize
- Scale text size
- E-Mail: [email protected]
- WeChat: ayst_shen
Copyright(c) 2018 Habo Shen <[email protected]>
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.