user1526671
user1526671

Reputation: 817

Scaling animation for entire text view android

I have a text view with background color. I want to enlarge/project the whole view using animation. I tried with scale animation only text gets enlarged.I want the whole view to get enlarged. Which animation should I use to attain this? Provide suggestions.

Upvotes: 0

Views: 3140

Answers (2)

Basim Sherif
Basim Sherif

Reputation: 5440

Add your textview to a relative layout.And apply animation to that layout.

xml:

<RelativeLayout
    android:layout_width="300dp"
    android:id="@+id/mylayout"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="218dp"
    android:background="#000" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="TextView"
        android:textColor="#fff" />

</RelativeLayout>

Java:

ScaleAnimation animation = new ScaleAnimation(fromXscale, toXscale, fromYscale, toYscale, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);

RelativeLayout rl=(RelativeLayout)findViewById(R.id.mylayout);

rl.startAnimation(animation);

Upvotes: 2

Saad
Saad

Reputation: 309

You can insert the textView in relative layout, set the id of relative Layout and do the scale animation to the relative Layout....

Upvotes: 0

Related Questions