安卓Glide错误:找不到crossFade()方法的符号。

4

当我尝试从Gmail帐户显示图像时,使用Glide时出现“无法解析符号方法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 中显示为红色,如下图所示:

screenshot 我尝试了来自 Stack Overflow 的以下解决方案,但它们都对我无效:

我该如何解决这个错误?

1个回答

0

这可能有点老了,但如果其他人卡住了

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);


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接