2

I'm trying to have an auto scroll Text-view vertically when video is playing. My text is too long to fit the screen and I want to auto scroll it when activity started. I followed every tutorial or tips posted here on stack-overflow but I couldn't figure out.

Here my class file:

public class TextSrcollActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_text_srcoll);

    TextView tv=(TextView)findViewById(R.id.textView1);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setSelected(true);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.text_srcoll, menu);
    return true;
}
}

And here is my XML file:

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:background="#ff737373"
android:gravity="center"
android:minWidth="64dp"
android:orientation="vertical"
android:padding="3dp" >
<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:marqueeRepeatLimit="marquee_forever"
    android:maxWidth="100px"
    android:scrollHorizontally="false"
    android:scrollbars="vertical"
    android:gravity="bottom"
    android:singleLine="false"
    android:textColor="#ffd9d9d9"
    android:textSize="16sp"/>
</LinearLayout>

In the XML file, I tried to change some properties but I still have nothing.

guneraykut
  • 181
  • 14

2 Answers2

0

use a textview inside a scrollview..

<ScrollView   
android:id="@+id/ScrollView01"  
android:layout_height="fill_parent"   
android:layout_width="fill_parent">

<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxWidth="100px"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:gravity="bottom"
android:singleLine="false"
android:textColor="#ffd9d9d9"
android:textSize="16sp"/>

</ScrollView>
williamj949
  • 11,166
  • 8
  • 37
  • 51
0

There is a problem with ellipsize on multiline textviews. This is an old issue with a bug report here: http://code.google.com/p/android/issues/detail?id=2254

There is a workaround at the bottom of the bug report, and another right here on SO: android ellipsize multiline textview

Community
  • 1
  • 1
rusmus
  • 1,665
  • 11
  • 18
  • How can I implement this [link](http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview/6763689#6763689) in order to auto scrolling? – guneraykut Feb 28 '14 at 14:50
  • If you look at the second link, the answer contains a custom textview. If you replace the standard android textview with the custom textview, the autoscrolling should work. The modification of an existing view type, and how to use it is described in the docs here: http://developer.android.com/guide/topics/ui/custom-components.html#modifying – rusmus Feb 28 '14 at 14:54
  • I implemented but I still same problem. text now looks like this: myText... I changed xml as – guneraykut Feb 28 '14 at 15:58