Android Glide错误:找不到符号方法crossFade()

时间:2018-12-01 11:36:48

标签: android android-studio android-glide

尝试从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中以红色显示,如下图:

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

如何克服此错误?

1 个答案:

答案 0 :(得分: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);