Skip to content Skip to sidebar Skip to footer

How To Insert An Image With Canvas?

I´m trying to insert a simple image with canvas in Android with the next code, but when i try to execute in the smartphone, only appears a white screen without image. import andr

Solution 1:

I found the answer: I add a view (Lienzo) to the layout. Answer found in this spanish web.

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RelativeLayout layout1 = (RelativeLayout) findViewById(R.id.layout1);
    Lienzo image = new Lienzo(this);
    layout1.addView(image);     
}

Thanks Xavier Falempin, you inspired me.


Post a Comment for "How To Insert An Image With Canvas?"