How can I fit an Image into another imageview
- by user1597833
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:
http://imgur.com/OM79T
http://imgur.com/G7y3Q