Note that there are some explanatory texts on larger screens.

plurals
  1. POScale up the TextView on first Touch, scale down on second touch
    primarykey
    data
    text
    <p>I am comparatively new to Android.</p> <p>Description -</p> <p>I have a <code>LinearLayout</code> with <code>TextView</code>'s in it. I am adding the <code>TextView</code> dynamically.</p> <p>When I touch the <code>TextView</code>, I want it to <code>ScaleUp</code> and when I touch the same <code>TextView</code> again I want it to <code>ScaleDown</code>.</p> <p>My problems are - </p> <ol> <li>When a <code>TextView</code> is <code>scaled up</code> and any other <code>TextView</code> is <code>touched</code>. The older <code>TextView</code> should <code>scale down</code> and the new <code>touched</code> <code>TextView</code> should <code>scale up</code>.</li> <li>When I touch a <code>scaled up</code> <code>TextView</code> then this <code>TextView</code> should scale down.</li> </ol> <p><strong>This is what I have tried</strong></p> <p>I have 2 set xmls. 1 for scale up </p> <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;scale android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="3.0" android:toYScale="3.0" &gt; &lt;/scale&gt; </code></pre> <p></p> <p>and the other for scale down</p> <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;scale android:fromXScale="3.0" android:fromYScale="3.0" android:toXScale="1.0" android:toYScale="1.0" &gt; &lt;/scale&gt; </code></pre> <p></p> <p>My <code>Activity</code> class - </p> <pre><code>myTextView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (myTextView.getAnimation() == null) { Animation a = AnimationUtils.loadAnimation( getBaseContext(), R.anim.scale_up); a.setFillAfter(true); v.startAnimation(a); } else { v.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v1, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { Animation a1 = AnimationUtils .loadAnimation( getBaseContext(), R.anim.scale_down); a1.setFillAfter(true); v1.startAnimation(a1); } return true; } }); } } return false; } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload