Closed Leeeeerich closed 3 years ago
Hey @Leeeeerich,
I'm not understanding your issue. Are you saying (for example) if you have labels: label1
, label2
and label3
and set label1.labelText
that the labelText for label2
and label3
also changes? Same for background color?
If so, please post more of your code so I have more context. I'd need to see what references you're using when setting each label.
All right:
private fun setFilterListeners() {
updateStyleCheckedFilter(
binding.eFabFilterAll,
R.color.blueColor,
android.R.color.white,
android.R.color.white
)
binding.eFabFilterAll.setOnClickListener {
changeFilter(listOf())
updateStyleCheckedFilterAndResetOther(
binding.eFabFilterAll,
R.color.blueColor,
android.R.color.white,
android.R.color.white
)
}
binding.eFabFilterIssues.setOnClickListener {
changeFilter(listOf(PostType.ISSUE))
updateStyleCheckedFilterAndResetOther(
binding.eFabFilterIssues,
R.color.blueColor,
android.R.color.white,
android.R.color.white
)
}
binding.eFabFilterPosts.setOnClickListener {
changeFilter(listOf(PostType.POST))
updateStyleCheckedFilterAndResetOther(
binding.eFabFilterPosts,
R.color.blueColor,
android.R.color.white,
android.R.color.white
)
}
binding.eFabFilterOfferRequest.setOnClickListener {
changeFilter(listOf(PostType.OFFER, PostType.REQUEST))
updateStyleCheckedFilterAndResetOther(
binding.eFabFilterOfferRequest,
R.color.blueColor,
android.R.color.white,
android.R.color.white
)
}
}
private fun updateStyleCheckedFilterAndResetOther(
view: FabOption,
buttonColor: Int = android.R.color.white,
textColor: Int = android.R.color.black,
iconColor: Int = R.color.darkGrayColor,
) {
updateStyleCheckedFilter(binding.eFabFilterAll)
updateStyleCheckedFilter(binding.eFabFilterIssues)
updateStyleCheckedFilter(binding.eFabFilterOfferRequest)
updateStyleCheckedFilter(binding.eFabFilterPosts)
updateStyleCheckedFilter(view, buttonColor, textColor, iconColor)
}
private fun updateStyleCheckedFilter(
view: FabOption,
buttonColor: Int = android.R.color.white,
textColor: Int = android.R.color.black,
iconColor: Int = R.color.darkGrayColor,
) {
view.fabOptionIcon?.setTint(getColor(iconColor))
view.fabOptionColor = buttonColor
view.label.labelTextColor = textColor
view.label.labelBackgroundColor = buttonColor
}
<com.nambimobile.widgets.efab.ExpandableFabLayout
android:id="@+id/expandableFabLayoutFilters"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.nambimobile.widgets.efab.ExpandableFab
android:id="@+id/eFabFilters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="10dp"
android:layout_marginBottom="65dp"
app:efab_icon="@drawable/ic_filter"
app:efab_orientation="portrait"
app:fab_openingAnimationDurationMs="25" />
<com.nambimobile.widgets.efab.FabOption
android:id="@+id/eFabFilterOfferRequest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_closingAnimationDurationMs="25"
app:fab_color="@android:color/white"
app:fab_icon="@drawable/ic_question"
app:fab_openingAnimationDurationMs="25"
app:fab_orientation="portrait"
app:label_backgroundColor="@android:color/white"
app:label_hiddenToVisibleAnimationDurationMs="75"
app:label_text="@string/offers_request"
app:label_textColor="@color/blackBlueColor"
app:label_visibleToHiddenAnimationDurationMs="75" />
<com.nambimobile.widgets.efab.FabOption
android:id="@+id/eFabFilterPosts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_closingAnimationDurationMs="25"
app:fab_color="@android:color/white"
app:fab_icon="@drawable/ic_post"
app:fab_openingAnimationDurationMs="25"
app:fab_orientation="portrait"
app:label_backgroundColor="@android:color/white"
app:label_hiddenToVisibleAnimationDurationMs="75"
app:label_text="@string/posts"
app:label_textColor="@color/blackBlueColor"
app:label_visibleToHiddenAnimationDurationMs="75" />
<com.nambimobile.widgets.efab.FabOption
android:id="@+id/eFabFilterIssues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_closingAnimationDurationMs="25"
app:fab_color="@android:color/white"
app:fab_icon="@drawable/ic_issue"
app:fab_openingAnimationDurationMs="25"
app:fab_orientation="portrait"
app:label_backgroundColor="@android:color/white"
app:label_hiddenToVisibleAnimationDurationMs="75"
app:label_text="@string/issues"
app:label_textColor="@color/blackBlueColor"
app:label_visibleToHiddenAnimationDurationMs="75" />
<com.nambimobile.widgets.efab.FabOption
android:id="@+id/eFabFilterAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_closingAnimationDurationMs="25"
app:fab_color="@android:color/white"
app:fab_icon="@drawable/ic_notes"
app:fab_openingAnimationDurationMs="25"
app:fab_orientation="portrait"
app:label_backgroundColor="@android:color/white"
app:label_hiddenToVisibleAnimationDurationMs="75"
app:label_text="@string/all_posts"
app:label_textColor="@color/blackBlueColor"
app:label_visibleToHiddenAnimationDurationMs="75" />
<com.nambimobile.widgets.efab.Overlay
android:layout_width="match_parent"
android:layout_height="match_parent"
app:overlay_color="@color/overlayColor"
app:overlay_orientation="portrait" />
</com.nambimobile.widgets.efab.ExpandableFabLayout>
Hey @Leeeeerich,
Please read the documentation when using the library. Colors cannot be set using R
constants, as those are references to resources, not actual colors.
For example, the documentation for labelBackgroundColor
specifically says:
The color of the Label's background, as an integer in the form 0xAARRGGBB.
If using an XML resource color value, retrieve it in the correct form by calling: ContextCompat.getColor(context, R.color.name_of_color_resource).
Sorry, my bad! I can't found a link to document info. Thanks for the link.
@Leeeeerich for future reference, links to the documentation are on the library's website.
JavaDoc: https://nambicompany.github.io/expandable-fab/javadoc/ KDoc: https://nambicompany.github.io/expandable-fab/kdoc/
You should also consider telling Android Studio (or whatever IDE you use) to download the sources of the library. This will allow you to see all the documentation right from your IDE. Every public method in the library is well documented with comments.
Hey! How I can change the color programmatically for fabOption: button, labelBackground, labelText?
If I changing color for an icon it normally works, but when I changing the color for the button, labelBackground, labelText and changing the text for the label, all my labels changing to a new color and text.
P.S. And the new button color, not that was which set.