以编程方式更改PorterShapeImageView的图像?

时间:2016-06-21 10:59:18

标签: android android-imageview

我使用this link来塑造ImageView,但它只接受我从xml中的drawable中获取的形状,它似乎无法以编程方式更改它?

这是代码

 <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" />

1 个答案:

答案 0 :(得分:0)

嗯,PorterShapeImageView是标准android.widget.ImageView的后代,因此您应该可以使用ImageView方法之一更改图像:

mPorterShapeImageView.setImageBitmap(mBitmap);

mPorterShapeImageView.setImageDrawable(mDrawable);

mPorterShapeImageView.setImageIcon(mIcon);

mPorterShapeImageView.setImageResource(R.drawable.new_image);

mPorterShapeImageView.setImageURI(mUri);
相关问题