如何从 Facebook 登录 sdk 中删除 ProgressBar

How to remove the ProgressBar from Facebook login sdk

通过使用 android 实现 Facebook 登录,我需要将令牌发送到我的后端服务器,所以我想知道我是否可以删除进度条并创建我自己的进度,在获得Facebook 令牌并发送到我的服务器。当我打电话时出现:

LoginManager.getInstance().logInWithReadPermissions(Login.this,Arrays.asList("email"));

您可以像这样删除 Facebook 登录进度条:

values/styles.xml中添加如下样式:

<style name="Translucent" parent="Translucent.Base"/>

<style name="InvisibleProgress">
    <item name="android:visibility">gone</item>
</style>

<style name="Translucent.Base" parent="android:Theme.Translucent.NoTitleBar">
    <item name="android:progressBarStyle">@style/InvisibleProgress</item>
</style>

values-v21/styles.xml中添加如下样式:

<style name="Translucent" parent="Translucent.Base">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

然后,在你的AndroidManifest.xml覆盖FacebookActivity的主题:

<manifest
  ...
  xmlns:tools="http://schemas.android.com/tools"
>

...

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@style/Translucent"
    tools:replace="android:theme"
/>

现在你不会看到Facebook进度条了,你可以自己画:)

在您的清单中 com.facebook.FacebookActivity

像下面这样更改主题

android:theme="@android:style/Theme.NoDisplay"

而不是

android:theme="@android:style/Theme.Translucent.NoTitleBar"