I want the text in a button to scroll...so for this i am using Text View on the button.
I have set following attributes in the layout. but it's not working.
I am using this in a RelativeLayout
...can anyone tell me whats wrong with my code?
<TextView
android:id="@+id/textView1"
android:text="Single-line text view that scrolls automatically if the text is too long to fit in the widget"
android:layout_width="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:layout_height="wrap_content"/>
I got solution and i am sharing this ...i created a class
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
public class ScrollingTextView extends TextView {
public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollingTextView(Context context) {
super(context);
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
as I needed more then one TextView
to be scrolled on a screen...
next in layout.xml
file used this....
<com.yourpackage.ScrollingTextView
android:id="@+id/TextView01"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:padding="5dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="1.option" />
and voila....it's done