ThreeColorIndicator
这是一个 Android 三色状态指示进度条,常用于指示:信号强度、温度等,可通过文字、颜色表示一个值的好、一般、差,也可以自定义为其它状态。
预览图
使用
Gradle
修改项目 build.gradle,增加如下代码:
dependencies {
compile 'com.ayst.tci:threecolorindicator:1.0.3'
}
Java
public class MainActivity extends AppCompatActivity {
private ThreeColorIndicator mThreeColorIndicator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mThreeColorIndicator = (ThreeColorIndicator) findViewById(R.id.indicator);
mThreeColorIndicator.setValue(80);
}
}
XML
<com.ayst.view.ThreeColorIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tci_min="0"
app:tci_max="100"
app:tci_firstColor="@color/red"
app:tci_secondColor="@color/yellow"
app:tci_thirdColor="@color/green"
app:tci_progressHeight="20dp"
app:tci_progressRadius="0px"
app:tci_firstRange="30"
app:tci_secondRange="20"
app:tci_value="80"
app:tci_firstText="Poor"
app:tci_secondText="Fair"
app:tci_thirdText="Good"
app:tci_indicatorText="-20dBm"
app:tci_indicatorTextColor="@android:color/white"
app:tci_indicatorTextSize="12sp"
app:tci_indicatorTextWidth="50dp"
app:tci_indicatorTextHeight="12sp"
app:tci_indicatorDrawable="@mipmap/ic_three_color_indicator"
/>
NOTE:
-
tci_firstColor
- First range color -
tci_secondColor
- Second range color -
tci_thirdColor
- Third range color -
tci_max
- Max value -
tci_min
- Min value -
tci_value
- Value -
tci_progressHeight
- Progress bar height -
tci_progressRadius
- Progress radius -
tci_firstRange
- This is a percentage, starting with the minimum value, showing first color within this percentage -
tci_secondRange
- This is a percentage, starting with the first range, showing second color within this percentage -
tci_firstText
- First Range indicator text -
tci_secondText
- Second Range indicator text -
tci_thirdText
- Third Range indicator text -
tci_indicatorText
- Indicator text -
tci_indicatorTextColor
- Indicator text color -
tci_indicatorTextSize
- Indicator text size -
tci_indicatorTextWidth
- Indicator text width -
tci_indicatorTextHeight
- Indicator text height -
tci_indicatorDrawable
- Indicator icon id