I have a file apple.9.png in my drawables folder and am trying to call this inside of my onDraw method.
Drawable d = getResources().getDrawable(getContext(), android.support.v4.R.drawable.apple);
in order to call canvas.drawPicture()
However, the word apple is red and it is telling me cannot resolve symbol 'apple'
Why cant it recognize the apple.9.png in the drawables folder?
I have also tried
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), android.support.v4.R.drawable.apple);
the word apple is red and it is telling me cannot resolve symbol 'apple'
This is because the image apple
is not part of android support library and since you are specifying it to find image in support library, it gives cannot resolve symbol
To fix this use:
Drawable d = getResources().getDrawable(getContext(), R.drawable.apple);
This will refer to your drawable
folder, and it will find image of apple.
For creating scaled Bitmap, refer link
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.