I'm printing text views almost full, so I think it'd be nice if I could scroll through them. What should I do?
final TextView tv = new TextView(this);
tv.setBackgroundResource(R.drawable.splash);
tv.setTypeface(face);
tv.setTextSize(18);
tv.setTextColor(R.color.BROWN);
tv.setGravity(Gravity.CENTER_VERTICAL| Gravity.CENTER_HORIZONTAL);
tv.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v, MotionEvent e)
{
Random r = new Random();
int i = r.nextInt(101);
if (e.getAction() == e.ACTION_DOWN)
{
tv.setText(tips[i]);
tv.setBackgroundResource(R.drawable.inner);
}
return true;
}
});
setContentView(tv);
There is also a way to put it in the scroll view, but more than that, like this
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
It's more convenient to go to a layout xml file with a text view and put the properties above into the text view.
In Java code,
text view.setMovementMethod(new ScrollingMovementMethod());
Do it like this.
© 2024 OneMinuteCode. All rights reserved.