I have either enabled scrolling for Android textview or by putting it in ScrollView or Alternatively, the Text Widget's Setting (Example, MyTextView.setMovementMethod (new scrollingwallmov ());)
However, I would ideally like to see TextView Scrolls in fashion like an iPhone / iPod Touch, where the text returns overhounds and bounce backs. In the emulator, a TextView simply scrolls to the beginning or the end without any animation effect.
Is this an easy way to enable scrolling behavior or Android animation capabilities and any other approach that uses OvershootInterpolator?
I had problems like you: A few hours after thorough research I made it:
Your xml layout , you have something like this:
& lt; HorizontalScrollView Android: AD = "@ + ID / Scroll" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: fadingEdgeLength = "0dp" Android: scrollbars = "none" & gt; & Lt; TextView Android: id = "@ + id / textview" Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: maxLines = "1" /> & Lt; / HorizontalScrollView & gt;
And now the fun part:
private text view mTextView ... private animation mnimation ... private zeros animateTextView () {int textWidth = GetTextViewWidth (mTextView); Int displayWidth = getDisplayWidth (mContext); / * Animation only start when the text display is longer than the width. * / If (displayWidth & lt; textWidth) {mAnimation = New Translation Name (0, Display Width-textWidth, 0, 0); MAnimation.setDuration (3000); // Set Custom Period mAnimation.setStartOffset (500); // Set custom offset mAnimation.setRepeatMode (Animation.REVERSE); // This text will be backed up, it reaches the end. MAnimation.setRepeatCount (Animation.INFINITE); // eternal animation mTextView.startAnimation (mAnimation); }} Private InDisplayWith {reference reference} {int displayWidth; Window Manager Window Manager = (Window Manager) context.getSystemService (Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay (); Point Screen Size = New Point (); If (Build.VERSION.SDK_INT> = Build.VERSION_CODES.HONEYCOMB_MR2) {display.getSize (Screen Size); DisplayWidth = screenSize.x; } And {displayWidth = display.getWidth (); } Return display width; } Private intuitiveview (textview text view) {textView.measure (0, 0); // is required to measure (0, 0). Return textView.getMeasuredWidth (); }
This animation is doing exactly what you want.
Comments
Post a Comment