어떻게 비트 맵을 XML 모양 드로어 블에서 가져올 수 있습니까? 내가 뭘 잘못하고 있니?xml에 정의 된 드로어 블에서 비트 맵을 얻는 방법은 무엇입니까?
shadow.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="270.0"
android:endColor="@android:color/transparent"
android:startColor="#33000000"
android:type="linear" />
<size android:height="7.0dip" />
</shape>
그리기에서 비트 맵 내 검색 방법에 전달 된 ID가 shadow.xml 때
private Bitmap getBitmap(int id) {
return BitmapFactory.decodeResource(getContext().getResources(), id);
}
getBitmap()는 널 (null)을 반환 drawable id.
좋은 설명에 감사드립니다. 캔버스에 직접 그려서 잘 작동했습니다. – kaneda
@ kaneda 마지막으로 작동 한 코드를 표시 할 수 있습니까? 나는 여기 같은 문제에 직면하고있다. 고마워. –
그럴 줄 알았는데 'Drawable d = getContext(). getResources(). getDrawable (R.drawable.id);' 'd.draw (canvas);' – Punksmurf