Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ビューをビットマップに変換しようとしています。エミュレーターでは、プログラムは正常に動作し、期待どおりに実行されていますが、デバイスで同じコードを実行すると、特定の行でnullポインター例外が発生します。
Bitmap b = Bitmap.createBitmap(view.getDrawingCache());
ここで、viewは、現在のアクティビティのレイアウトを持つRelativeLayoutのオブジェクトです。誰かがこの問題を解決する方法を教えてもらえますか?ありがとう。
を使用する前に、ビューでmeasureとを呼び出す必要があります。それ以外の場合は null を返します。layoutgetDrawingCache()
measure
layout
getDrawingCache()