2016-08-09 57 views
0

我是Android新手,我需要以圓形的形式顯示圖像,但是一些圖像比自定義的圓形圖像視圖具有更多的寬度和高度,然後將圖像顯示爲拉伸形式,但是我想用縮小的圖像顯示圖像圖像大小和圈顯示。我正在使用通用圖像加載器來加載圖像。請幫助我如何做到這一點。如何在圓圈圖像視圖中顯示完整圖像而不拖動?

在此先感謝

+0

嘗試在通用圖像加載器使用.displayer(新RoundedBitmapDisplayer(PX)) –

+0

已經使用這個與大小但仍然問題正在生產。我的尺寸爲309 * 99,我需要在尺寸上顯示爲150 * 150。 –

+0

使用http://square.github.io/picasso/加載圖像 –

回答

0

build.gradle文件,把該行的相關性:

compile 'de.hdodenhof:circleimageview:2.0.0' 

這是圓形的ImageView庫。那麼你可以在xml中使用它:

<de.hdodenhof.circleimageview.CircleImageView 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/profile_image" 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:scaleType="fitCenter" 
    android:src="@drawable/male_profile_image" 
    app:civ_border_width="0dp"/> 
+0

已經使用它,但問題仍然存在。 –

0

你可以使用第三方庫CircularImageView。把你的依賴以下

compile 'com.mikhaellopez:circularimageview:3.0.2' 

替換爲您ImageView以下

<com.mikhaellopez.circularimageview.CircularImageView 
     android:id="@+id/profile_image" 
     android:layout_width="250dp" 
     android:layout_height="250dp" 
     app:civ_border_color="#EEEEEE" 
     app:civ_border_width="4dp" 
     app:civ_shadow="true" 
     app:civ_shadow_radius="10" 
     app:civ_shadow_color="#8BC34A"/> 

然後

CircularImageView circularImageView = (CircularImageView)findViewById(R.id.profile_image); 

ImageLoader imageLoader = ImageLoader.getInstance(); 
imageLoader.displayImage(imageUri, circularImageView);