2

I am making a textView animate like the cast list after movie (slide into the screen and slide out the screen), however, the textView is unable to display all my text even I use wrap_content.

The animation goes, and suddenly the text are being cropped The text was incomplete

The layout xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f2f1ef"
    android:clipChildren="false"
    android:paddingBottom="150dp"
    android:paddingLeft="30dp"
    android:paddingRight="30dp"
    android:paddingTop="150dp" >

    <TextView
        android:id="@+id/story_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing"
    android:textSize="60sp" />

</LinearLayout>

Slide up animation, slideup_in.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:fromYDelta="125%"
    android:toYDelta="-150%"
    android:duration="20000" />

Activity:

public class StoryActivity extends Activity {

   TextView story_txt;
   Animation animationSlideDownIn;

   @Override
   public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_story);

        story_txt = (TextView) findViewById(R.id.story_txt);

        Typeface face = Typeface
            .createFromAsset(getAssets(), "font/secret.ttf");

        story_txt.setTypeface(face);

        animationSlideDownIn = AnimationUtils.loadAnimation(this,
            R.anim.slideup_in);

      animationSlideDownIn.setAnimationListener(animationSlideInListener);

        story_txt.startAnimation(animationSlideDownIn);
      }

   AnimationListener animationSlideInListener = new AnimationListener() {

    @Override
    public void onAnimationEnd(Animation arg0) {
        story_txt.setVisibility(View.INVISIBLE);
        finish();
    }

   };
}
h3lL0W0RLd
  • 79
  • 3
  • 9

3 Answers3

0
android:toYDelta="-150%"

This code will allow you to run the textview above the original position. If you want to make it back to its original position, please use

android:toYDelta="100%"
oldfeel
  • 420
  • 3
  • 12
  • The animation is what I want to do and is is correct, the problem is the textview could not display complete text – h3lL0W0RLd Mar 26 '15 at 14:50
  • http://stackoverflow.com/questions/18048997/android-view-disappearing-when-go-outside-of-parent – oldfeel Mar 26 '15 at 14:56
  • My textview does not disappear, it show incomplete text. And I have already use android:clipChildren="false" to the layout – h3lL0W0RLd Mar 26 '15 at 15:03
0

You have this problem because of android:paddingBottom="150dp" and android:paddingTop="150dp" Remove these, and the problem should be gone.

Your layout XML should look like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f2f1ef"
    android:clipChildren="false"
    android:paddingLeft="30dp"
    android:paddingRight="30dp">

    <TextView
        android:id="@+id/story_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing"
    android:textSize="60sp" />

</LinearLayout>

If you do want padding at the top and bottom, you should use a smaller value, such as 15dp. 150dp is too much, and results in the text not filling the available space.

Jonas Czech
  • 12,018
  • 6
  • 44
  • 65
  • Tried, still got the problem. It is not the padding cropping my textview, but the textview itself is not long enough – h3lL0W0RLd Mar 26 '15 at 14:59
0

The problem here is that your TextView will have a maximum height value equal to your screen height (not considering the paddings). That happens because you have a LinearLayout as your layout parent View. And your TextView content needs more than your screen height so you can see it entirely.

If you change it to a ScrollView, all your content will be entirely visible, because ScrollView, obviously, has no limitation in what concerns its content height.

joao2fast4u
  • 6,868
  • 5
  • 28
  • 42