I am working on AR core android and i want to put text Label on touch. I am successfully able to put object on surface using openGL and GLsurfaceview but i want to add text Label on surface and i don't want to use Sceneform.
In Sceneform i am able to do it like this.i want same thing using openGL
private void placeObject(ArFragment fragment, Anchor anchor, Uri model,String myText) {
LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.text_view, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(10, 10);
params.setMargins(45, 0, 5, 0);
TextView dynamicTextBackground = new TextView(this);
dynamicTextBackground.setLayoutParams(params);
dynamicTextBackground.setBackgroundColor(Color.YELLOW);
dynamicTextBackground.setText("1");
dynamicTextBackground.setTextSize(1);
TextView dynamicTextView = new TextView(this);
dynamicTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
dynamicTextView.setText(myText);
dynamicTextView.setBackgroundColor(Color.WHITE);
dynamicTextView.setTextColor(Color.RED);
dynamicTextView.setPadding(2, 2, 2, 2);
dynamicTextBackground.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.badge_circle));
linearLayout.addView(dynamicTextBackground);
linearLayout.addView(dynamicTextView);
ViewRenderable.builder()
.setView(this,linearLayout)
.build()
.thenAccept(renderable -> addNodeToScene(fragment, anchor, renderable))
.exceptionally((throwable -> {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(throwable.getMessage())
.setTitle("Error!");
AlertDialog dialog = builder.create();
dialog.show();
return null;
}));
}