1
我是新來的android開發,我現在正在開發一個項目。該項目是關於使用位圖將圖片加載到屏幕上的。將圖片加載到屏幕後,我想在加載的位圖頂部添加一些圖標/繪圖,然後保存。如何在大位圖上繪製圖標?
這是我的代碼的一部分,用於加載一個單一的圖像到屏幕上。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
case SELECT_PICTURE_ACTIVITY_REQUEST_CODE:
if (resultCode == RESULT_OK){
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn,
null, null, null);
if (cursor.moveToFirst()){
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
targetImage.setImageBitmap(bitmap);
}
cursor.close();
}
break;
}
}
這裏是我的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ImageView>
我的XML代碼包含只是一個,這意味着整個屏幕要用於顯示我的照片。
現在,我面臨一個問題,如何加載一些圖標或繪製在我的位圖頂部,然後保存它?我在我的選項菜單中有一個「添加」選項,我期望當我在選項菜單中按下「添加」按鈕時,在我的可繪製文件中有一個列表顯示一些圖標/可繪製,並且在我選擇一個圖標後,所選圖標將出現在我原始位圖圖片的頂部。此外,我希望我可以拖動圖標到任意位置,然後保存它。
請給我一個幫助,這是非常迫切的!
非常感謝!