I have an ImageView, and on a click I want to replace its image with a bigger one, but there seems to be a problem. The image stretches downwards but it should extend upwards. I have tried to do it dynamically as well via XML, but it’s not working.
// addnews button on the first screen
final ImageView addnewsback = (ImageView)findViewById(R.id.newslistback);
ImageView addnews = (ImageView)findViewById(R.id.newslistbtn);
addnews.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
addnewsback.setImageResource(R.drawable.bgbig);
vf.setDisplayedChild(0);
}
});

<RelativeLayout
android:id="@+id/c1"
android:layout_marginTop="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_alignParentLeft="true">
<ImageView
android:id="@+id/newslistback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/holderview"
android:src="@drawable/bg" />
<ImageView
android:id="@+id/newslistbtn"
android:layout_marginLeft="14dp"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/newslisticon" />
</RelativeLayout>
Try to use relativelayout with background images as its own background and not new imageview it would reduce the clutter and dont try to give then a size and use appropriate graphic size.