2017-03-01 122 views
1

我正在使用毕加索图像并试图将图像放入圆形图像视图中,但图片仍为正方形。我该如何解决它?如何将图像放在圆形图像视图中

Picasso.with(context).load(resId).resizeDimen(R.dimen.image_size, R.dimen.image_size).into(holder.mImageViewItem); 

IMAGE_SIZE = 60dp

绘制资源:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="oval"> 
<solid android:color="#FFF"/> 

和ImageView的:

<ImageView 
    android:id="@+id/picture_imageview_item" 
    android:layout_marginTop="15dp" 
    android:layout_marginLeft="25dp" 
    android:layout_marginBottom="15dp" 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:background="@drawable/buttonshape" /> 

回答

0

你可以用白色边框和透明的一个简单的圆形内容与形状。

// res/drawable/circle.xml 

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:innerRadius="0dp" 
    android:shape="ring" 
    android:thicknessRatio="1.9" 
    android:useLevel="false" > 
    <solid android:color="@android:color/transparent" /> 

    <stroke 
     android:width="10dp" 
     android:color="@android:color/white" /> 
</shape> 

然后创建一个可绘制的图层列表,并将其作为背景添加到您的图像视图中。

// res/drawable/img.xml 

    <?xml version="1.0" encoding="utf-8"?> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

     <item android:drawable="@drawable/ic_launcher"/> 
     <item android:drawable="@drawable/circle"/> 

    </layer-list> 

并将其作为背景添加到您的imageview。

<ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/img"/> 

代替ic_launcher,您可以添加图像。 谢谢!

+0

抱歉,但它的犯规帮助我。悲伤:( –

+0

有什么问题? –

+0

没有什么变化:(会尝试使用一些库 –

0

您可以使用不同的库来创建圆形图像。这是我遇到的最好的一个是

Siyamed