How to show movable text in Android using Open GL?? Or is their any other way that show text movement without any jerk. I have tried Android animation and marquee but it was not reducing jerk. I need text moving on single line coming in from right and going out to left like in news headlines. In Open GL what should i do in renderer??
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
touchStart = new PointF();
objs = new GLSurfaceView(this);
sqobj = new rendsquare();
objs.setRenderer(sqobj);
setContentView(objs);
TextView editBox = new TextView(getApplicationContext());
editBox.setTextColor(Color.BLUE);
editBox.setEllipsize(TruncateAt.MARQUEE);
editBox.setMarqueeRepeatLimit(-1);
editBox.setHorizontallyScrolling(true);
editBox.setFocusable(true);
editBox.setFocusableInTouchMode(true);
editBox.setText("Hello GL testing 123 hello hello h r u i am fine hello u there hello! hello !! !! !! !!");
addContentView(editBox, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
//Other one
public class SquaropnglActivity extends Activity {
private rendsquare sqobj;
private PointF touchStart;
private GLSurfaceView objs;
Animation mAnimation = new TranslateAnimation(300f, -300f, 0.0f, 0.0f);
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
touchStart = new PointF();
objs = new GLSurfaceView(this);
sqobj = new rendsquare();
objs.setRenderer(sqobj);
setContentView(objs);
mAnimation.setRepeatMode(1);
mAnimation.setInterpolator(new DecelerateInterpolator());
mAnimation.setDuration(3000L);
mAnimation.setRepeatCount(-1);
TextView editBox = new TextView(getApplicationContext());
editBox.setTextColor(Color.BLUE);
editBox.setAnimation(mAnimation);
editBox.setTextSize(40);
editBox.setLines(1);
editBox.setText("Hello GL testing 123 hello hello h r u i am fine hello u there hello! hello !! !! !! !!");
addContentView(editBox, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
}
If you want do text rendering in opengl way, please write text drawing logic in your
onDrawFrame(gl)
method and update text position on each frame update to have marquee animation.
For text rendering, please look into OpenGL Text Rendering
Haven't tested it. It should work for you. Best wishes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With