How can I fit an Image into another imageview
Posted
by
user1597833
on Stack Overflow
See other posts from Stack Overflow
or by user1597833
Published on 2012-10-18T09:19:36Z
Indexed on
2012/10/21
11:01 UTC
Read the original article
Hit count: 225
android
|android-imageview
I have an imageview with a default image already set from the xml, and I want to change it's image pragmatically so that the new image will scale to the previous image size, both of the images are rounded.
I have tried setting the scaleType attribute to different values before setting the new image but it didn't work.
This is the xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/up_right_circle_firstiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:src="@drawable/circle_medium_up" />
This is the activity code:
public class MainActivity extends Activity {
ImageView middleCircle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
middleCircle = (ImageView) findViewById(R.id.up_right_circle_firstiv);
middleCircle.setImageResource(R.drawable.round_pic_one);
}
}
Inside the activity.
I have uploaded the screenshots:
© Stack Overflow or respective owner