Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is how I did it in a custom view I created. I had the view I wanted to display already coded into the xml layout file with <code>android:visibility = "gone"</code>. The only thing I haven't figured out yet is when the EditText box is scaling, it enlarges the text, then shrinks it to normal size. If I find a solution to this problem I will post it.</p> <pre><code>private EditText m_editText; protected void onFinishInflate () { super.onFinishInflate (); m_editText = (EditText) findViewById(R.id.edit_text); } public void displayView(View activateView) { if (activateView.getVisibility() == View.GONE) { //fade in from top activateView.setVisibility(View.VISIBLE); final Animation fadeInFromTopAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in_from_top); fadeInFromTopAnimation.setAnimationListener(new AnimationListener() { public void onAnimationStart(Animation anim) { //Shrink the text box down while inserting new view //Add any padding or margins if needed float scale = (float)(m_editText.getHeight() + m_weatherRow.getHeight()) / m_editText.getHeight(); AnimationSet shrinkDownAnimation = new AnimationSet(true); shrinkDownAnimation.setInterpolator(new LinearInterpolator()); ScaleAnimation scaleAnimation = new ScaleAnimation(1, 1, //X Scale scale, 1, //Y Scale Animation.RELATIVE_TO_SELF, 0.5f, //X Pivot Point (set to center but it shouldn't matter) Animation.RELATIVE_TO_SELF, 1.0f); //Y Pivot Point (bottom) scaleAnimation.setDuration(fadeInFromTopAnimation.getDuration()); shrinkDownAnimation.addAnimation(scaleAnimation); m_editText.startAnimation(shrinkDownAnimation); } public void onAnimationEnd(Animation anim) {} public void onAnimationRepeat(Animation anim) {} }); activateView.startAnimation(fadeInFromTopAnimation); </code></pre> <p>And here is my <code>fade_in_from_top.xml</code> animation file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android = "http://schemas.android.com/apk/res/android" android:interpolator = "@android:anim/linear_interpolator"&gt; &lt;alpha android:fromAlpha = "0" android:toAlpha = "1" android:duration = "500"&gt; &lt;/alpha&gt; &lt;scale android:fromXScale = "1" android:fromYScale = "0" android:toXScale = "1" android:toYScale = "1" android:pivotX = "50%" android:pivotY = "0%" android:duration = "500"&gt; &lt;/scale&gt; &lt;/set&gt; </code></pre>
 

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