I have a wallpaper app, which sets a selected image as background for the phone's menu. It is scrollable (by default), but the problem is that the background is just a cutout of the original image. Here is my code to set the image as background:
private Bitmap image = [...];
[...]
private void setBackgroundImage(){
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
try {
wallpaperManager.setBitmap(pic);
} catch (IOException e) {
e.printStackTrace();
}
}
My question now is: How can I determine the right size for the image, so that every phone has the entire picture as it's background picture and not just a cutout?
my java file: like this
public class MainActivity extends AppCompatActivity {
Button button;
ImageView imageView;
WallpaperManager wallpaperManager ;
Bitmap bitmap1, bitmap2 ;
DisplayMetrics displayMetrics ;
int width, height;
BitmapDrawable bitmapDrawable ;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.button);
imageView = (ImageView)findViewById(R.id.imageView);
wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
bitmapDrawable = (BitmapDrawable) imageView.getDrawable();
bitmap1 = bitmapDrawable.getBitmap();
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
GetScreenWidthHeight();
SetBitmapSize();
wallpaperManager = WallpaperManager.getInstance(MainActivity.this);
try {
wallpaperManager.setBitmap(bitmap2);
wallpaperManager.suggestDesiredDimensions(width, height);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
public void GetScreenWidthHeight(){
displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
width = displayMetrics.widthPixels;
height = displayMetrics.heightPixels;
Toast.makeText(MainActivity.this,"width:"+width+", height:"+height,Toast.LENGTH_SHORT).show();
}
public void SetBitmapSize(){
bitmap2 = Bitmap.createScaledBitmap(bitmap1, width, height, false);
}
}
and my layout file. like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageView"
android:src="#drawable/sample_image_wallpaper"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click here to Set this image as Wallpaper in android programmatically"
android:id="#+id/button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="94dp" />
</RelativeLayout>
Hope this will help.
Related
please any help , i'm trying to set image as wallpaper i get this image by her url
i'm working with Glide Library i tried this code Set image as wallpaper from url but doesn't work for me please any help for resolve this issue?
file.java :
public class Pop extends Activity {
int width,height;
String url;
LinearLayout llsetwallpapers;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pop);
llsetwallpapers = (LinearLayout)findViewById(R.id.llSetWallpaper);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
this.width = dm.widthPixels;
this.height = dm.heightPixels;
getWindow().setLayout((int) (((double) this.width) * 0.9d), (int) (((double) this.height) * 0.75d));
getIntent().getSerializableExtra("WallpaperURL");
this.url = (String)getIntent().getSerializableExtra("WallpaperURL");
Glide.with(getApplicationContext()).load(this.url).into((ImageView)findViewById(R.id.imageSelectTo));
llsetwallpapers.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// set as wallpapers
}
});
}
}
xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/linealL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#65000000">
<ImageView
android:id="#+id/imageSelectTo"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" />
<!-- Set as wallpaper button -->
<LinearLayout
android:id="#+id/llSetWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:background="#drawable/btn_rounded_corner"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_alignParentLeft="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="#string/SetAsWallpaper"
android:textColor="#color/white"
android:textSize="18sp" />
</LinearLayout>
<!-- Download wallpaper button -->
<LinearLayout
android:id="#+id/llDownloadWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/btn_rounded_corner"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="#string/Download"
android:textColor="#color/white"
android:textSize="18sp" />
</LinearLayout>
private ImageView userImageView;
userImageView = (ImageView) findViewById(R.id.user_image);
Glide.with(getApplicationContext()).load(yourImageUrl).asBitmap()
.error(yourDefaultImageUrl or from R.id.drawableDefaultImage).centerCrop().into(userImageView);
Try this code it take a url converts it into bitmap and then set wallpaper according to screen size :
Declare variables
ImageView mImageView;
WallpaperManager wallpaperManager;
Bitmap bitmap1, bitmap2;
DisplayMetrics displayMetrics; //to find screen dimensions
int width, height; //to find screen dimensions
BitmapDrawable bitmapDrawable;
Button downloadButton;
String url="your wallpaper url";
Initialise your Views
mImageView = (ImageView) findViewById(R.id.imageView);
downloadButton= (Button) findViewById(R.id.Button);
In onCreate
Glide.with(this).load(spacePhoto.getUrl()).asBitmap().listener(new RequestListener<String, Bitmap>() {
#Override
public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
return false;
}
#Override
public boolean onResourceReady(Bitmap resource, String model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
mImageView.setImageBitmap(resource);
//Code to set bitmap as wallpaper according to screen size
fabOptions.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
new Thread(new Runnable() {
#Override
public void run() {
wallpaperManager = WallpaperManager.getInstance(getApplication());
bitmapDrawable = (BitmapDrawable) mImageView.getDrawable();
bitmap1 = bitmapDrawable.getBitmap();
GetScreenWidthHeight();
bitmap2 = Bitmap.createScaledBitmap(bitmap1, width, height, false);
wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
try {
wallpaperManager.setBitmap(bitmap2);
wallpaperManager.suggestDesiredDimensions(width, height);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
Snackbar snackbar = Snackbar
.make(v, "Wallpaper Set", Snackbar.LENGTH_SHORT);
snackbar.show();
}
});
return false;
}
}).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(mImageView);
Write this code outside of onCreate
public void GetScreenWidthHeight() {
displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
width = displayMetrics.widthPixels;
height = displayMetrics.heightPixels;
}
I have a recycle view to show all photo thumbnail items. When click on item, I use transition for imageview in this item to Detail activity. The problem is that image source is gotten from internet by UIL. And sometime (not always) the images not reload correct size like this:
// on view holder item click
final Pair<View, String>[] pairs = TransitionHelper.createSafeTransitionParticipants(this, false,
new Pair<>(((ItemViewHolder) viewHolder).thumbnail, getString(R.string.TransitionName_Profile_Image)),
new Pair<>(((ItemViewHolder) viewHolder).tvName, getString(R.string.TransitionName_Profile_Name)));
ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this, pairs);
startActivityForResult(intent, requestCode, transitionActivityOptions.toBundle());
Detail activity
// try to post pone transition until UIL load finish
ActivityCompat.postponeEnterTransition(this);
getSupportFragmentManager().beginTransaction().replace(R.id.layoutContent, new DetailFragment()).commit();
Fragment Detail
ImageLoader.getInstance().displayImage(url, imageViewDetail, new ImageLoadingListener() {
#Override
public void onLoadingStarted(String imageUri, View view) {
}
#Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
finishAnimation();
}
#Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
finishAnimation();
}
#Override
public void onLoadingCancelled(String imageUri, View view) {
finishAnimation();
}
});
private void finishAnimation(){
ActivityCompat.startPostponedEnterTransition(getActivity());
imageViewDetail.invalidate();
}
fragment_detail.xml
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:transitionName="#string/TransitionName.Profile.Image"
android:id="#+id/imageViewDetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>
</FrameLayout>
I even wait views are laid out before load image but still not work:
imageViewDetail.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
#Override
public boolean onPreDraw() {
// code load image from UIL
return false;
}
});
Is there any way to avoid this issue?
this xml can handle diferent image size
<ScrollView
android:id="#+id/vScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="51dp"
android:scrollbars="none" >
<HorizontalScrollView
android:id="#+id/hScroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imgFullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
in java
fullImageView = (ImageView) findViewById(R.id.imgFullscreen);
selectedPhoto = (FeedItem) i.getSerializableExtra(TAG_SEL_IMAGE);
zoom = 1;
if (selectedPhoto != null) {
fetchFullResolutionImage();
} else {
Toast.makeText(getApplicationContext(),
getString(R.string.msg_unknown_error), Toast.LENGTH_SHORT)
.show();
}
private void fetchFullResolutionImage() {
try {
final URL url = new URL(selectedPhoto.getImge());
new Thread(new Runnable() {
#Override
public void run() {
try {
Bitmap bmp = BitmapFactory.decodeStream(url
.openStream());
if (bmp != null)
setImage(bmp);
else {
showToast("Error fetching image!");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
} catch (IOException e) {
e.printStackTrace();
}
}
private void setImage(final Bitmap bmp) {
runOnUiThread(new Runnable() {
public void run() {
fullImageView.setImageBitmap(bmp);
adjustImageAspect(selectedPhoto.getWidth(),
selectedPhoto.getHeight());
}
});
}
private void adjustImageAspect(int bWidth, int bHeight) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
if (bWidth == 0 || bHeight == 0)
return;
int swidth;
if (android.os.Build.VERSION.SDK_INT >= 13) {
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
swidth = size.x;
} else {
Display display = getWindowManager().getDefaultDisplay();
swidth = display.getWidth();
}
int new_height = 0;
new_height = swidth * bHeight / bWidth;
params.width = swidth;
params.height = new_height;
saveW = swidth;
saveH = new_height;
fullImageView.setLayoutParams(params);
}
I'm really new at this and I'm trying to load profile pics from gallery and camera into ImageButton. I'm able to add image from gallery but the image does not fit completely into the ImageButton. Some space still gets left out from the imagebutton. I want the image to automatically fit into imagebutton.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sam.sport.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/LL1" >
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" >
<ImageButton
android:id="#+id/profile_pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher"
android:scaleType="fitXY"
android:adjustViewBounds="true" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Activity class is as below:-
public class MainActivity extends Activity {
ImageButton ib;
private static Bitmap Image = null;
private static final int GALLERY = 1;
private static Bitmap rotateImage = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ib = (ImageButton)findViewById(R.id.profile_pic);
ib.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
ib.setImageBitmap(null);
if (Image != null)
Image.recycle();
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == GALLERY && resultCode != 0) {
Uri mImageUri = data.getData();
try {
Image = Media.getBitmap(this.getContentResolver(), mImageUri);
if (getOrientation(getApplicationContext(), mImageUri) != 0) {
Matrix matrix = new Matrix();
matrix.postRotate(getOrientation(getApplicationContext(), mImageUri));
if (rotateImage != null)
rotateImage.recycle();
rotateImage = Bitmap.createBitmap(Image, 0, 0, Image.getWidth(), Image.getHeight(), matrix,
true);
ib.setImageBitmap(rotateImage);
} else
ib.setImageBitmap(Image);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static int getOrientation(Context context, Uri photoUri) {
/* it's on the external media. */
Cursor cursor = context.getContentResolver().query(photoUri,
new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null);
if (cursor.getCount() != 1) {
return -1;
}
cursor.moveToFirst();
return cursor.getInt(0);
}
}
Convert it to Drawable then use setBackgroundDrawable insted of setImageBitmap
Drawable drawable = new BitmapDrawable(rotateImage);
ib.setBackgroundDrawable(drawable);
Use below line of code for re-sizing your bitmap
Bitmap BITMAP_IMAGE = Bitmap.createBitmap(IMAGE_VIEW.getWidth(),IMAGE_VIEW.getHeight(), Bitmap.Config.RGB_565);
Bitmap resizedBitmap = Bitmap.createScaledBitmap(BITMAP_IMAGE, 100, 100, false); ////Here BITMAP_IMAGE is your bitmap which you want to resize
Get the imageButton height and width
Bitmap bitmapScaled = Bitmap.createScaledBitmap(Image, ib_width, ib_height, true);
Drawable drawable = new BitmapDrawable(bitmapScaled);
ib.setBackgroundDrawable(drawable);
Keep in mind about OOM exception.
To get imageButton height and width look into this and this
I've got the perfect solution. To resize imageview I used the below code as provided in the [Android ImageView adjusting parent's height and fitting width
public class ResizableImageView extends ImageView {
public ResizableImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
Drawable d = getDrawable();
if(d!=null){
// ceil not round - avoid thin vertical gaps along the left/right edges
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = (int) Math.ceil((float) width * (float) d.getIntrinsicHeight() / (float) d.getIntrinsicWidth());
setMeasuredDimension(width, height);
}else{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
]1
I used the the below code to rotate the image. There is no problem in image rotation, but when i rotate the image the image pixels was reduced. if i rotate continuously means the image will disappeared. How can i solve this problem.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/test" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="66dp"
android:text="Click here to Rotate" />
</RelativeLayout>
ImageResizeTestActivity.java
public class ImageResizeTestActivity extends Activity {
/** Called when the activity is first created. */
Button click;
ImageView img;
static File rotated_File;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
click = (Button) findViewById(R.id.button1);
img = (ImageView) findViewById(R.id.imageView1);
String fname = "Rotated_Image.jpg";
rotated_File = new File("/sdcard/" + fname);
click.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (!(rotated_File.exists())) {
Log.v("Inside if", "if");
rotateImage();
} else {
Log.v("Inside else", "else");
rotateImage(rotated_File.getAbsolutePath());
}
}
});
}
protected void rotateImage(String absolutePath) {
// TODO Auto-generated method stub
Bitmap myImg = BitmapFactory.decodeFile(absolutePath);
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(),
myImg.getHeight(), matrix, true);
saveImage_Rotate(rotated);
img.setImageBitmap(rotated);
}
protected void rotateImage() {
// TODO Auto-generated method stub
Bitmap myImg = BitmapFactory.decodeResource(getResources(),
R.drawable.test);
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(),
myImg.getHeight(), matrix, true);
saveImage_Rotate(rotated);
img.setImageBitmap(rotated);
}
static void saveImage_Rotate(Bitmap dest2) {
if (rotated_File.exists())
rotated_File.delete();
try {
FileOutputStream out = new FileOutputStream(rotated_File);
dest2.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
after rotating
A quick look on the problem. You save the jpg several times, and during the (lossy)compression it will degrade more and more.
I'd suggest you use png instead
i'd like to load a picture from sdcard into my view then draw upon it. so far i can take the picture and display it in an imageview after i've drawn a circle on the bitmap but this is not how it should be done. I think that i need to create a custom view class and override it's onDraw(). Atm i have a relative layout with a surfaceview, after the surfaceview i have the imageview and buttons. My question is if i write a custom view class to handle the drawing, i would then pass that to my activity's setContent view, what is confusing me is if the layout is declared declaratively via the xml file, how can i set the activity's setContentView() to the custom view class that handles the drawing?
thanks mat
[edit]
here's the xml layout i'm using. this is not how i should do it using an imageview.
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="fill">
<ImageView android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></ImageView>
<com.tecmark.HorizontalSlider android:id="#+id/slider"
android:indeterminateOnly="false"
android:progressDrawable="#android:drawable/progress_horizontal"
android:indeterminateDrawable="#android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip"
android:maxHeight="20dip" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
public class LoadPic extends Activity{
private static final String TAG = "Loadpic";
private ImageView imageview;
private File tempFile;
private byte[] imageArray;
private HorizontalSlider slider;
private Canvas canvas;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Log.e(TAG, " loadpic onCreate");
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.load2);
setProgressBarVisibility(true);
slider = (HorizontalSlider) this.findViewById(R.id.slider);
slider.setOnProgressChangeListener(changeListener);
imageview = (ImageView)findViewById(R.id.imageView1);
tempFile = new File(Environment.getExternalStorageDirectory().
getAbsolutePath() + "/"+"image.jpg");
imageArray = new byte[(int)tempFile.length()];
try{
InputStream is = new FileInputStream(tempFile);
BufferedInputStream bis = new BufferedInputStream(is);
DataInputStream dis = new DataInputStream(bis);
int i = 0;
while (dis.available() > 0) {
imageArray[i] = dis.readByte();
i++;
}
dis.close();
} catch (Exception e) {
e.printStackTrace();
}
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inSampleSize = 5;
Bitmap bm = BitmapFactory.decodeByteArray(imageArray, 0, imageArray.length, bfo);
Log.e(TAG, bm.toString());
//imageview.setImageBitmap(bm);
Bitmap bmOverlay = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), bm.getConfig());
canvas = new Canvas(bmOverlay);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStrokeWidth(1);
paint.setStyle(Paint.Style.STROKE);
canvas.drawBitmap(bm, new Matrix(), null);
canvas.drawCircle(50, 50, 25, paint);
imageview.setImageBitmap(bmOverlay);
}// end of onCreate
private OnProgressChangeListener changeListener = new OnProgressChangeListener() {
#Override
public void onProgressChanged(View v, int progress) {
// TODO Auto-generated method stub
setProgress(progress);
}
};
}//end of Activity
What i'm thinking of doing is creating a customview class that handles the drawing on the bitmap. But if i do this then how do i make setContentView() to point to my customView class when it point to the xml file. Sorry if i missing something here.
If you want to have a custom view for the bitmap and drawing then you can simply extend ImageView and override the paint method. Something like that:
public class MyImage extends ImageView {
...
#Override
public void paint(...){}
}
And in the xml layout change the ImageView to
<what.ever.package.MyImage ... />