to add an answer to eboix ... this is how I disappear in the text and the text disappears, with a delay between each disappearance and until the disappearance, (immediately after fading).
My XML looks like this.
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:gravity="center" android:text="Retrieving Result" android:textColor="@color/general_app_colour" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/blobText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:gravity="center" android:text="Please Wait" /> </LinearLayout>
You use these variables in your activity / fragment / dialog fragment, the following variables that I used in my ...
public class Loading_Dialog extends DialogFragment { public String[] text = new String[]{""}; TextView blobText; Animation inAnimation; Animation displayLength; Animation delayAnimation; Animation outAnimation;
Now the objects and variables are initialized, they are used like this, I used this for my fragment of the dialogue in the oncreateDialog method.
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = new Dialog(getActivity(),R.style.LoadingDialogAnimation); dialog.getWindow().setContentView(R.layout.dialog_loading); blobText = (TextView) dialog.findViewById(R.id.blobText); inAnimation = new AlphaAnimation(0f, 1f); inAnimation.setDuration(fadeEffectDuration); displayLength = new AlphaAnimation(1f, 1f); displayLength.setDuration(displayFor); delayAnimation = new AlphaAnimation(0f, 0f); delayAnimation.setDuration(delayDuration); outAnimation = new AlphaAnimation(1f, 0f); outAnimation.setDuration(fadeEffectDuration); inAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { position++; if(position>=text.length) { position = 0; } blobText.setText(text[position]); } @Override public void onAnimationRepeat(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { blobText.startAnimation(displayLength); } }); displayLength.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) {
kunmi Mar 20 '14 at 13:32 2014-03-20 13:32
source share