0

I have a layout with some EditText fields to fill and one of them is a description, the problem is that the description box is too small and I want to achieve the following: when it will get clicked it will stretch to full screen width and will have a button there to finish writing it. I tried using a Fragment but it didn't work well for me but if you can give me an example for one who will give the result It will be great, another question: when the text box is stretched is there a way to make it as an effect that will look like it is stretching slowly until the maximum size?

Thanks guys

Christine
  • 5,617
  • 4
  • 38
  • 61
orisgoofo
  • 53
  • 1
  • 6

1 Answers1

0

you need to follow below steps 1) have a button there which you want to use for finish writing, and set its property to "invisible" or "gone" 2) set a listener for editbox ( using setOnClickListener ) which you said is too small 3) in listener write the code to increase the width, you will first need to get layoutParam from editbox, update width for layoutParam, and assign it back to edit box

to strech it you need to follow these steps 1) create animation xml in drawable/anim folder i.e. myAnim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
<scale android:fromXScale=".9"
    android:toXScale="1"
    android:fromYScale=".7"
    android:toYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="300"
    android:interpolator="@android:anim/linear_interpolator"/>
<alpha android:fromAlpha="0"
   android:toAlpha="1"
   android:duration="300"
   android:interpolator="@android:anim/linear_interpolator" />
</set>

2) Load above animation during create method Animation myAnimation= AnimationUtils.loadAnimation(this, R.anim.myAnimation);

3) call this code from listener mentioned in first part of my answer button.startAnimation(myAnimation);