0
我正在使用this link來塑造ImageView
但它只接受我從xml中繪製的形狀,它似乎不能以編程方式更改它?以編程方式更改PorterShapeImageView的圖像?
這是代碼
<com.pmb.pipcamera.activities.PorterShapeImageView
android:id="@+id/iv_effect_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="fitXY"
app:siShape="@drawable/pip1_overlay"
app:siSquare="false" />
我試過這個,但沒有運氣 Drawable d1 = new BitmapDrawable(getResources(),bitmap_main); iv_effect_main.setImageDrawable(d1); – user6428778
@ user6428778嗯,這很奇怪。我從來沒有使用這個庫,但它看起來並不像它覆蓋'ImageView'中的任何東西,這會阻止你這樣做。你有沒有嘗試其他方法? – Bryan
@ user6428778在庫中提供的示例中,Square的['Picasso'](http://square.github.io/picasso/)庫用於以編程方式設置圖像。 'Picasso'使用'ImageView.setImageDrawable()'方法來做到這一點,所以這些方法*應該工作。 – Bryan