1

Is it possible to scale only the top portion of a patch 9 image.

I am using two set of images inside a frame layout.

My objective is to animate scale an image(imageView2) to show the progress of a battery charge.(Its a patch 9 image created to scale vertically. imageView2

Against the background of a second image (vertical battery cell) imageView1

I have pasted the code that i am using currently.Currently The image stretches in both directions(on the y coordinates) and the bottom round corners loses its shape and drops outside the background at the bottom.

I want to retain the bottom round shape intact. And please tell me how i can limit the scaling to be within the bounds of the background image.

    <FrameLayout android:layout_width="wrap_content"
            android:layout_height="fill_parent" android:layout_gravity="right">

            <ImageView android:layout_width="wrap_content" android:id="@+id/imageView1"
                android:layout_gravity="bottom" android:layout_height="wrap_content"
                android:src="@drawable/battery_charge_background"></ImageView>
        <ImageView android:layout_width="wrap_content" android:id="@+id/imageView2"
                 android:layout_gravity="bottom"

                android:layout_height="wrap_content" 
                android:src="@drawable/battery_charge_fill_empty"
                ></ImageView> 

ScaleAnimation scale = new ScaleAnimation((float)1.0, (float)1.0, (float)1.0, (float)8.0, Animation.RELATIVE_TO_SELF, (float)0.8, Animation.RELATIVE_TO_SELF, (float)0.7);
scale.setFillAfter(true);
scale.setDuration(1000);
imageView.startAnimation(scale); 
Dmitri
  • 26
  • 1
  • 5

0 Answers0