7

I tried to use the following style

<style name= "AuthStyle">
<item name="android:windowBackground">@drawable/culture</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>

and then I applied the above style here:

startActivityForResult(AuthUI.getInstance()
                .createSignInIntentBuilder()
                .setProviders(AuthUI.EMAIL_PROVIDER,
                              AuthUI.FACEBOOK_PROVIDER,
                              AuthUI.GOOGLE_PROVIDER)
                .setTheme(R.style.AuthStyle)
                .build()
                ,1);

However,the title bar is still being displayed. Any suggestions on how to remove / hide it will be appreciated

Fahad Saleem
  • 413
  • 2
  • 13
  • If that currently isn't possible, it sounds like it's a better fit as a [feature request on the FirebaseUI repo](https://github.com/firebase/FirebaseUI-Android/issues). – Frank van Puffelen Aug 25 '16 at 14:21
  • Thanks for that: https://github.com/firebase/FirebaseUI-Android/issues/266 – Frank van Puffelen Aug 25 '16 at 15:16
  • 1
    It turns out that removing titlebar is possible. This user used the same code as me, however his titlebar does not show while mine does: https://github.com/firebase/FirebaseUI-Android/issues/229 – Fahad Saleem Aug 25 '16 at 15:18

2 Answers2

5

Firebase UI overrides/ignores the removal of the action bar/app bar in the theme, so we have to cheat. In styles.xml:

<style name="AppThemeFirebaseAuth" parent="android:Theme.Material.Light.NoActionBar">
    <item name="android:actionBarStyle">@style/FirebaseAuthActionBarStyle</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="FirebaseAuthActionBarStyle" parent="Widget.AppCompat.ActionBar">
    <item name="android:background">@color/white</item>
</style>

(or rather than @color/white, whatever your background colour.)

Where you start the activity for sign in:

    Intent signInIntent = AuthUI.getInstance().createSignInIntentBuilder()
            .setProviders(Arrays.asList(
                    new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                    new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
            .setTheme(R.style.AppThemeFirebaseAuth)
            .setLogo(R.drawable.logo)
            .setIsSmartLockEnabled(!BuildConfig.DEBUG)
            .build();

Keep in mind that in future releases of Firebase UI, the action bar/app bar might become useful or required, so this is a bit dangerous.

Eliot
  • 2,349
  • 3
  • 28
  • 45
5

As of firebase ui version 4.3.1, the following code is enough to hide tiltebar, no need to do tricks with background color:

<style name="AppThemeFirebaseAuth" parent="android:Theme.Light.NoTitleBar">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

just reference the style when creating AuthUI instance

// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
    new AuthUI.IdpConfig.PhoneBuilder().build());
AuthUI.createSignInIntentBuilder()
      .setAvailableProviders(providers)
      .setTheme(R.style.AppThemeFirebaseAuth)
      .build(),

Tested in android 4.4.2 and android 9 (Nexus emulators)

Kartu
  • 51
  • 1
  • 5