Android 之 Fresco 显示圆形图片 之坑

来源:互联网 发布:智能电视点歌软件 编辑:程序博客网 时间:2024/05/21 16:03

前言

用Fresco 显示 Android 图片,本来是想圆形图片显示的。可是折腾了半天还是方形图片,最后发现是命名空间的问题。

xml 文件

xml 文件如下:

<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:fresco="http://schemas.android.com/tools"    android:id="@+id/cv_item"    android:layout_width="match_parent"    android:layout_height="wrap_content"    app:cardCornerRadius="5dp"    app:cardElevation="5dp"    app:contentPadding="2dp">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="horizontal">        <com.facebook.drawee.view.SimpleDraweeView            android:id="@+id/rcv_article_photo"            android:layout_width="100dp"            android:layout_height="100dp"            fresco:actualImageScaleType="centerInside"            fresco:roundAsCircle="true"           fresco:roundingBorderColor="@color/lightslategray"            fresco:roundingBorderWidth="1dp" />        <LinearLayout            android:layout_width="0dp"            android:layout_height="match_parent"            android:layout_weight="1"            android:orientation="vertical">            <TextView                android:id="@+id/rcv_article_title"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginLeft="10dp"                android:layout_marginTop="2dp"                android:gravity="center"                android:text="关于举办《经典音乐作品欣赏与人文审美》讲座的通知"                android:textColor="@color/primary_text" />            <!-- 新闻 发布时间 来源 阅读次数-->            <LinearLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:layout_marginTop="5dp"                android:gravity="center"                android:orientation="horizontal">                <TextView                    android:id="@+id/rcv_article_date"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_marginLeft="10dp"                    android:layout_marginRight="2dp"                    android:text="2015-01-09" />                <TextView                    android:id="@+id/rcv_article_source"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_marginLeft="2dp"                    android:layout_marginRight="2dp"                    android:text="科学研究院" />                <TextView                    android:id="@+id/rcv_article_readtimes"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_marginLeft="2dp"                    android:layout_marginRight="2dp"                    android:text="1129次" />            </LinearLayout>            <TextView                android:id="@+id/rcv_article_preview"                android:layout_width="wrap_content"                android:layout_height="0dp"                android:layout_weight="1"                android:layout_marginLeft="10dp"                android:layout_marginTop="5dp"                android:ellipsize="end"                android:maxLines="2"                android:text="讲座主要内容:以中、西方音乐历史中经典音乐作品为基础,通过作曲家及作品创作背景、相关音乐文化史知识及音乐欣赏常识..." />        </LinearLayout>    </LinearLayout></android.support.v7.widget.CardView>

有了这几行设置,

fresco:roundAsCircle="true"            fresco:roundingBorderColor="@color/lightslategray"fresco:roundingBorderWidth="1dp"

预期左边是圆形图片,可是左边还是不正确。
fresco 图片

解决方案

把上面的

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

改为

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

studio 修复问题的时候按command+1 导入的 schemas.android.com/tools,正确的应该是/apk/res-auto
圆形图片

4 0
原创粉丝点击