Opengl Android中的可移动文本

时间:2012-06-18 11:37:28

标签: android opengl-es

如何使用Open GL在Android中显示可移动文本?或者是他们的任何其他方式显示文本运动没有任何混蛋。我已经尝试过Android动画和选框,但它并没有减少混蛋。我需要从正确的单行进入文本,然后像新闻标题一样向左走。在Open GL中我应该在渲染器中做什么?

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));
}

//其他人

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));
}

}

1 个答案:

答案 0 :(得分:1)

如果您想以opengl方式进行文本渲染,请在您的文本中编写文本绘图逻辑 onDrawFrame(gl) 方法并更新每个帧更新上的文本位置以使用选框动画。

对于文字渲染,请查看OpenGL Text Rendering

尚未测试过。它应该适合你。祝福。