【问题标题】:Android Glide error: cannot find symbol method crossFade()Android Glide 错误:找不到符号方法 crossFade()
【发布时间】:2019-05-03 08:50:22
【问题描述】:

在尝试显示来自 Gmail 帐户的图像时,我在 Glide 中收到 cannot resolve symbol method crossFade() 错误。

private void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();

        Log.e(TAG, "display name: " + acct.getDisplayName());

        String personName = acct.getDisplayName();
        if(acct.getPhotoUrl() != null){

            personPhotoUrl = acct.getPhotoUrl().toString();
        }
        String email = acct.getEmail();

        Log.e(TAG, "Name: " + personName + ", email: " + email + ", Image: " + personPhotoUrl);
        txtName.setText(personName);
        txtEmail.setText(email);
        Glide.with(getApplicationContext()).load(personPhotoUrl).thumbnail(0.5f).crossFade().diskCacheStrategy(DiskCacheStrategy.ALL).into(imgProfilePic);


        updateUI(true);
    }
    else {
        // Signed out, show unauthenticated UI.
        updateUI(false);
    }
}

请注意,crossFade() 在我的 Android Studio 中显示为红色,如下图所示:

我尝试了 Stack Overflow 的以下解决方案,但没有一个对我有用。

我该如何克服这个错误?

【问题讨论】:

    标签: android android-studio android-glide


    【解决方案1】:

    这有点旧,但如果其他人卡住了 Glide.with(getApplicationContext()).load(personPhotoUrl).thumbnail(0.5f).crossFade().diskCacheStrategy(DiskCacheStrategy.ALL).into(imgProfilePic);

    改成

    Glide.with(getApplicationContext()).load(personPhotoUrl).thumbnail(0.5f).transition(withCrossFade()).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgProfilePic);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多