An Android custom view library to display data with color coded information in a Linear bar format with labels to indentfy each color. Is use by ShopperApp application (shopper-app-new).
Step 1. Add it in root build.gradle
at the end of repositories:
allprojects {
repositories {
TODO: pending
}
}
Step 2. Add the dependency
dependencies {
TODO: pending
}
Step 1. Add component to Layout file
<com.shopper.customviews.LinearStateBar
android:id="@+id/linear_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Step 2. Custom the view.
app:fontSize="12" -> Can modify the fontSize
app:heightLineStatus="10" -> Can modify the height of LinearBar
Step 3. Set a List<DataModelState>
and the total value of items.
DataModelView(
val dataList: List<DataModelState>,
val totalValue: Int
)
DataModelState(
val label: String,
val value: Int,
val color: Int
)
DataModelView(
dataList = listOf(
DataModelState("Label 1", 10, color),
DataModelState("Label 2", 15, color),
DataModelState("Label 3", 5, color)
),
totalValue = 20
)
- The second param on DataModelView is the entire span linear bar view.
- And value param in each DataModelState object will occupy a percent length.
- Width of each item is calculated by
model.value / range * viewWidth
.
Step 4. Refer this View in your activity/fragment file, getting the id component (linearBar) and set data:
binding.linearBar.setDataModelView(List<DataModelState>, totalValue)
Be free to use it and enjoy. ⭐
Copyright 2020
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.