android - 如何更改 Firebase UI (Android) 国家代码选择器中文本的颜色
问题描述
我在我的应用程序中使用 Firebase UI 4.0.1,它通过以下主题使用AuthUI.getInstance().createSignInIntentBuilder().setTheme(R.style.LoginTheme)
<style name="Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<item name="colorAccent">@color/secondaryColor</item>
<item name="android:windowBackground">@color/primaryColor</item>
</style>
<style name="Base.AppTheme">
<!-- Customize your theme here. -->
<item name="android:editTextStyle">@style/Yas_EditTextStyle</item>
<item name="editTextStyle">@style/Yas_EditTextStyle</item>
<item name="android:textColor">@color/primaryTextColor</item>
</style>
<style name="AppTheme" parent="Base.AppTheme">
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="LoginTheme" parent="@style/Base">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:alertDialogStyle">@style/Login_AlertDialogStyle</item>
</style>
<style name="Login_AlertDialogStyle" parent="@style/AlertDialog.AppCompat.Light">
<item name="android:textColorAlertDialogListItem">@android:color/black</item>
<item name="android:textColor">@android:color/black</item>
</style>
注意primaryTextColor
是白色的。当我这样做时,一切看起来都很好,直到我打开国家代码选择器的警报对话框。在那里我得到一个国家列表,但文本是白色背景上的白色。我试图让该文本变为黑色,但它在白色上显示为白色。这是正在调用的对话框类的链接:https ://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/ui/phone/CountryListSpinner .java#L163
如何确保 Firebase UI 使用我的Login_AlertDialogStyle
?
解决方案
尝试将此添加到您的 FirebaseUI 主题:
<item name="android:alertDialogTheme">@style/Login_AlertDialogStyle</item>
您首先需要在您的 中创建一个自定义 FirebaseUI 主题styles.xml
,该主题必须从 FirebaseUI 扩展。然后,您需要通过 AuthUI 构建器设置此样式:
样式.xml
<style name="SignInTheme" parent="FirebaseUI">
<item name="android:alertDialogTheme">@style/Login_AlertDialogStyle</item>
<!-- Feel free to add anything else you want here -->
</style>
活动类
Intent firebaseAuth = AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.SignInTheme) // set your sign in theme here
.setAvailableProviders(Arrays.asList(
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build()))
.build();
有关自定义 UI 的更多信息:https ://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md#ui-customization
推荐阅读
- javascript - Gulp - 排除变量文件名
- javascript - 当 SCSS 中有多个 div 并排时,大纲不会完全包裹 div
- twitter-bootstrap - 导航栏仅显示为无功能的汉堡菜单
- asp.net - 登录失败:未知用户名或错误密码错误
- python - 创建新 Shapefile 时使用 PyShp 的多部分形状问题
- sql - SQL在SQL Server上删除没有主键的表中的重复行
- python - GridSearchCV 对平均绝对误差的评分
- android - 如何在 Android 中将 ViewModel 与来自存储库(数据库/网络)的 LiveData 一起使用?
- ruby - 使用 Ruby 的 Open3 / Process.spawn() 捕获 ANSI 彩色输出
- javascript - Waypoints JS 找不到变量