我是Android新手,我需要以圓形的形式顯示圖像,但是一些圖像比自定義的圓形圖像視圖具有更多的寬度和高度,然後將圖像顯示爲拉伸形式,但是我想用縮小的圖像顯示圖像圖像大小和圈顯示。我正在使用通用圖像加載器來加載圖像。請幫助我如何做到這一點。如何在圓圈圖像視圖中顯示完整圖像而不拖動?
在此先感謝
我是Android新手,我需要以圓形的形式顯示圖像,但是一些圖像比自定義的圓形圖像視圖具有更多的寬度和高度,然後將圖像顯示爲拉伸形式,但是我想用縮小的圖像顯示圖像圖像大小和圈顯示。我正在使用通用圖像加載器來加載圖像。請幫助我如何做到這一點。如何在圓圈圖像視圖中顯示完整圖像而不拖動?
在此先感謝
在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"/>
已經使用它,但問題仍然存在。 –
你可以使用第三方庫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);
嘗試在通用圖像加載器使用.displayer(新RoundedBitmapDisplayer(PX)) –
已經使用這個與大小但仍然問題正在生產。我的尺寸爲309 * 99,我需要在尺寸上顯示爲150 * 150。 –
使用http://square.github.io/picasso/加載圖像 –