🔋A simple charging view.
一个简单的充电view
在根目录的build.gradle添加这一句代码:
allprojects {
repositories {
//...
maven { url 'https://jitpack.io' }
}
}
在app目录下的build.gradle添加依赖使用:
dependencies {
implementation 'com.github.samlss:ChargingView:1.1'
}
布局中使用:
<com.iigo.library.ChargingView
android:id="@+id/cv2"
android:layout_marginTop="10dp"
android:layout_width="100dp"
android:layout_height="200dp"
app:progress="50"
app:progressTextColor="@android:color/black"
app:chargingColor="@android:color/holo_red_light"
app:bg_color="#eeeeee"
app:progressTextSize="20dp" ></com.iigo.library.ChargingView>
代码中使用:
chargingView.setProgress(95);
chargingView.setBgColor(Color.parseColor("#aaaaaa"));
chargingView.setChargingColor(Color.YELLOW);
chargingView.setTextColor(Color.RED);
chargingView.setTextSize(25);
属性说明:
属性 | 说明 |
---|---|
bg_color | 背景颜色 |
chargingColor | 充电中颜色 |
progress | 当前进度0-100 |
progressTextSize | 显示进度text大小 |
progressTextColor | 显示进度text颜色 |
如果不能满足你的需要,你可以下载源码自行修改。
A simple charging view.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
//...
maven { url 'https://jitpack.io' }
}
}
Add it in your app build.gradle at the end of repositories:
dependencies {
implementation 'com.github.samlss:ChargingView:1.1'
}
in layout.xml:
<com.iigo.library.ChargingView
android:id="@+id/cv2"
android:layout_marginTop="10dp"
android:layout_width="100dp"
android:layout_height="200dp"
app:progress="50"
app:progressTextColor="@android:color/black"
app:chargingColor="@android:color/holo_red_light"
app:bg_color="#eeeeee"
app:progressTextSize="20dp" ></com.iigo.library.ChargingView>
in java code:
chargingView.setProgress(95);
chargingView.setBgColor(Color.parseColor("#aaaaaa"));
chargingView.setChargingColor(Color.YELLOW);
chargingView.setTextColor(Color.RED);
chargingView.setTextSize(25);
Attributes description:
attr | description |
---|---|
bg_color | the background color |
chargingColor | the charging color |
progress | current progress:0-100 |
progressTextSize | the progress text size |
progressTextColor | the progress text color |
If you can not meet your needs, you can download the source code to modify it.
Copyright (c) 2018 samlss
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.