其他分享
首页 > 其他分享> > android – 我在Fresco中遇到圆形图像问题

android – 我在Fresco中遇到圆形图像问题

作者:互联网

我有圆形图像的问题,不起作用,壁画下载图像和显示但不转换为圆形.我不知道我错过了这是我的代码.

摇篮:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
    applicationId "pruebas.imaginamos.com.pruebas"
    minSdkVersion 21
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.facebook.fresco:fresco:0.14.1'
    testCompile 'junit:junit:4.12'
   //compile 'com.mostafagazar:customshapeimageview:1.0.4'
   // If your app supports Android versions before Ice Cream Sandwich (API level 14)
   compile 'com.facebook.fresco:animated-base-support:0.14.1'

}

这是MainActivity5.java:

package pruebas.imaginamos.com.pruebas;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.facebook.drawee.view.SimpleDraweeView;

public class MainActivity5 extends AppCompatActivity {

   SimpleDraweeView simpleDraweeView;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        String url = "https://firebasestorage.googleapis.com/v0/b/farmatodo-dev.appspot.com/o/imChat%2F2e4120c7-3755-4537-aceb-c2ed9d97ad01%2F1479745196209-about-06.jpg?alt=media&token=fb0c3c8a-eeac-488b-96d2-51bc7cbd088a";

        Uri uri = Uri.parse(url);


        simpleDraweeView = (SimpleDraweeView) findViewById(R.id.avatarImageView);
        simpleDraweeView.setImageURI(uri);


}

}

这是activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fresco="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="pruebas.imaginamos.com.pruebas.MainActivity5">


<RelativeLayout
    android:layout_width="match_parent"
    android:background="@color/colorAccentLight"
    android:layout_height="wrap_content">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/avatarImageView"
        android:layout_width="100dp"
        android:layout_height="100dp"
        fresco:placeholderImageScaleType="centerCrop"
        fresco:placeholderImage="@drawable/photo_female_3"
        fresco:roundAsCircle="true"/>
</RelativeLayout>

</LinearLayout>

解决方法:

替换此行,

xmlns:fresco="http://schemas.android.com/tools"

在xml文件中使用此行,

xmlns:fresco="http://schemas.android.com/apk/res-auto"

标签:android,fresco
来源: https://codeday.me/bug/20190713/1453254.html