i am new to android development and i am now developing a project. This project is about loading a picture to the screen using bitmap. After loading the picture into the screen, i want to add some icon/drawable on top of the loaded bitmap and then save it.
Here is part of my codes which used for load a single image to the screen.
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;
}
}
Here is my xml code:
<?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>
my xml code contains just an which means the whole screen are going to used for displaying my picture.
Now, i am facing a problem with how to load some icons or drawable on top my bitmap and then save it? I have a “add” option in my optionmenu, i expect that when i press “add” button in the option menu, there is a list show some icon/drawables in my drawable file, and after i selected a icon, the selected icon will appear on top of my original bitmap picture. Also, i expect i can drag the icon to arbitrary location and then save it.
Please give me a help and it is very urgent!
Thanks a lot!
I’m not 100% sure why you are approaching the problem this way. I think a standard layout with the background set to your primary drawable would work better, but I believe a LayerDrawable is what you are looking for.