A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values.:bookmark:
Add below codes to your root build.gradle
file (not your module build.gradle file).
allprojects {
repositories {
mavenCentral()
}
}
And add a dependency code to your module's build.gradle
file.
dependencies {
implementation 'com.github.JustinGeorgeJoseph:MaterialChipsetWidget:v1.0.1'
}
We can use MaterialChipSetsContainer
without any customized attributes.
Initally there won't be any content you have add those contents dynamically.
<com.justin.materialchipsetwidget.MaterialChipSetsContainer
android:id="@+id/materialChipSetsContainer"
android:layout_width="match_parent"
android:scrollbars="none"
android:layout_height="wrap_content"/>
android:scrollbars="none" // sets whether a horizontal scrollbar is required or not.
private fun createDataSet(): List<List<String>> {
val arrayTime = arrayListOf("Recent", "2000s", "90s", "Old")
val arrayPurchaseMode = arrayListOf("Paid", "Rent")
val arrayGenre = arrayListOf("Action", "Comedy", "Sci-Fi", "Science", "Drama")
val arrayRating = arrayListOf("Award-winning", "Highly rated")
return arrayListOf(arrayPurchaseMode, arrayTime, arrayGenre, arrayRating)
}
findViewById<MaterialChipSetsContainer>(R.id.materialChipSetsContainer).apply {
chipSetSolidColorUnselected = ContextCompat.getColor(context, android.R.color.black)
chipSetSolidColorSelected = ContextCompat.getColor(context, R.color.green)
chipSetStrokeWidth = Utils.convertDpToPx(this@MainActivity, 3)
chipSetStrokeColorUnselected =
ColorStateList.valueOf(ContextCompat.getColor(context, R.color.green))
chipSetStrokeColorSelected =
ColorStateList.valueOf(ContextCompat.getColor(context, R.color.green))
chipTextColorUnselected = ContextCompat.getColor(context, android.R.color.white)
chipTextColorSelected = ContextCompat.getColor(context, android.R.color.white)
chipTextDividerColorUnselected =
ContextCompat.getColor(context, R.color.green)
dataSet = createDataSet()
}
MaterialChipsetWidgetListener {
override fun onChipSelectionChanged(
name: String?,
chipSelectionGroup: String,
checked: Boolean,
) {
}
override fun onChipsetsResetClicked() {
}
}
Copyright 2022 JustinGeorgeJoseph (Justin George)
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
https://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.