问题
I am using Firebase Auth Ui from number verification. I have some requirements where i need to change text and background color of country spinner's dropdown item. I am using this below style but it doesn't change the color of dropdown's background or item's text color.
style name="FirebaseUI.CountrySpinner" parent="Widget.AppCompat.Spinner.Underlined">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:dropDownItemStyle">@style/mySpinnerItemStyle</item>
</style>
<style name="mySpinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
<item name="android:textColor">@color/colorVerifyButtonText</item>
</style>
What am i doing wrong here, please help me out.
回答1:
You'll want to extend the FirebaseUI theme and pass that into the builder options. Example:
<style name="GreenTheme" parent="FirebaseUI">
<!-- Required for sign-in flow styling -->
<item name="colorPrimary">@color/material_green_500</item>
<item name="colorPrimaryDark">@color/material_green_700</item>
<item name="colorAccent">@color/material_purple_a700</item>
<item name="colorControlNormal">@color/material_green_500</item>
<item name="colorControlActivated">@color/material_lime_a700</item>
<item name="colorControlHighlight">@color/material_green_a200</item>
<item name="android:windowBackground">@color/material_green_50</item>
</style>
And in Java:
startActivityForResult(
AuthUI.getInstance(this).createSignInIntentBuilder()
// ...
.setTheme(R.style.GreenTheme)
.build());
And the docs: https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md#themes
You'll basically want to extend the FirebaseUI style with your drop-down attribute.
来源:https://stackoverflow.com/questions/49192361/how-to-customize-firebase-auth-ui