Question

I was wondering if it is possible to get shadows/shapes of icons on home screen in android? I know when you add some custom icon to your homescreen and then move it around you get outlines of that icon. ( at least in samsungs TouchWiz 4+ and API 11+ ). So is there a way to obtain shapes and locations of icons on homescreen?

Was it helpful?

Solution

Here is a short sample of what you could do:

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ImageView view = ((ImageView) findViewById(R.id.img_outline));
        view.setImageBitmap(createOutline(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)));
        view.setColorFilter(Color.RED);
    }

    private Bitmap createOutline(Bitmap src) {
        Paint p = new Paint();
        p.setMaskFilter(new BlurMaskFilter(10, Blur.OUTER));
        return src.extractAlpha(p, null);
    }
}

Is that what you had in mind? (Note that if you have to align the blurred image with the original you should pass an int array of length two to extractAlpha. The array will contain the offsets you should use to align the outline.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top