I wanted image to have rounded corners. I implement this xml code and use this in my image view. but image overlap the shape. I am downloading the image through async task.<
Your MainActivity.java
is like this:
LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
ImageView iv = (ImageView) findViewById(R.id.iv);
You should to first get your image from Resource as Bitmap
or Drawable
.
If get as Bitmap
:
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ash_arrow);
bm = new Newreza().setEffect(bm, 0.2f, ((ColorDrawable) ll.getBackground).getColor);
iv.setImageBitmap(bm);
Or if get as Drawable
:
Drawable d = getResources().getDrawable(R.drawable.ash_arrow);
d = new Newreza().setEffect(d, 0.2f, ((ColorDrawable) ll.getBackground).getColor);
iv.setImageDrawable(d);
Then create new file as Newreza.java
near MainActivity.java
, and copy bottom codes in Newreza.java
:
package your.package.name;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
//Telegram:@newreza
//mail:newreza7@gmail.com
public class Newreza{
int a,x,y;
float bmr;
public Bitmap setEffect(Bitmap bm,float radius,int color){
bm=bm.copy(Bitmap.Config.ARGB_8888,true);
bmr=radius*bm.getWidth();
for(y=0;y
Just notice that replace your package name with first line in the code.
It %100 works, because is written in details :)