Various sources for drawing refer to import android.graphics.Canvas; or import android.graphics.Path;

Android Studio does not know both options, there are no such libraries. Where can I get these libraries? Or is there an alternative for drawing simple shapes? (Circle, rectangle)

enter image description here

I am writing a project in android studio, created using libGDX

  • one
    Maybe you did not connect the SDK? These classes are taken from the standard SDK. And in libGDX, isn't it possible to implement all this with your own classes? - pavel163
  • @ pavel163 checked in the project structure, the path to sdk is specified correctly (D: \ sdk without it the project cannot be started) - StriBog
  • @ pavel163 and libgdx seems to be able to draw only textures, that is, there is SpriteBatch, in which, as I understand it, you can take the form of texture drawing, for example in a circle - StriBog
  • Delete this import and in the place where this class is used call ImportClass. You have everything correctly, maybe some kind of studio bug - Werder
  • Try invalidate cache and restart - Kostya Bakay

1 answer 1

Found such an alternative for drawing, from libgdx

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; ShapeRenderer sr= new ShapeRenderer(); sr.begin(ShapeRenderer.ShapeType.Line); sr.setColor(Color.RED); sr.rect(10,10,30,30); sr.end(); sr.isDrawing(); 
  • one
    That's what it is about. In pure Android Studio, drawing on the canvas is your own ways. And if you use Libgdx, then these are completely different ways. In fact, these are two different languages ​​(Libgdx is not for nothing called a framework). - Konstantin