Photo frame Script

Photo frame Script

I was only going to share this script with my 100% lightning layout but im waiting for Pierre to get back before doing that. Anyways i thought some people might like to use this as part of there own layouts. You can see it in the screenshot below its nothing special thats really all there is to it theres no fancy transition effects or slideshow or anything like that its just a static image displayed in a custom view. I was originally using a widget app to do this but its not 100% lightning if people gotta install other apps so i wrote this to replace the app. The Script is in post 2 all you need to do to use it is replace the path variable value with the location of your image.

« (Previous Post)
(Next Post) »

2 Commentsto Photo frame Script

  1. Jay M says:

    bindClass(“android.widget.FrameLayout“)

    bindClass(“android.widget.ImageView“);

    bindClass(“android.graphics.BitmapFactory“);

    bindClass(“android.widget.Button“);

    bindClass(“android.widget.LinearLayout“);

    bindClass(“android.view.Gravity“);

    bindClass(“android.view.View“);

    bindClass(“android.app.AlertDialog“);

    bindClass(“android.content.DialogInterface“);

    bindClass(“android.widget.ImageView.ScaleType“);

    var mctx = LL.getContext();

    /*

    * Paste the path to your image between the “”

    */

    var path = “/storage/emulated/0/Download/Taylor Swift.jpg“;

    var frame = new FrameLayout(mctx);

    var flp = new FrameLayout.LayoutParams(-1,-1);

    var iv = new ImageView(mctx);

    var image = BitmapFactory.decodeFile(path);

    iv.setImageBitmap(image);

    frame.addView(iv);

    var b = new Button(mctx);

    b.setBackgroundColor(0x000000);

    b.setText(“”);

    var blp = new LinearLayout.LayoutParams(-2,-2, Gravity.BOTTOM|Gravity.RIGHT);

    b.setLayoutParams(blp);

    frame.addView(b);

    var scale = {

    center:ImageView.ScaleType.CENTER,

    centerCrop:ImageView.ScaleType.CENTER_CROP,

    centerInside:ImageView.ScaleType.CENTER_INSIDE,

    fitCenter:ImageView.ScaleType.FIT_CENTER,

    fitEnd:ImageView.ScaleType.FIT_END,

    fitStart:ImageView.ScaleType.FIT_START,

    fitXY:ImageView.ScaleType.FIT_XY

    };

    iv.setScaleType(scale.centerCrop);

    var options = [];

    for (var keys in scale){

    options.push(keys);

    }

    b.setOnClickListener(new View.OnClickListener(){

    onClick:function(view){

    showDialog();

    }

    });

    function showDialog(){

    var adb = new AlertDialog.Builder(mctx);

    adb.setTitle(“Image ScaleType”);

    adb.setItems(options, new DialogInterface.OnClickListener(){

    onClick:function(dialog, which){

    switch((which +1)){

    case 1:

    iv.setScaleType(scale.center);

    break;

    case 2:

    iv.setScaleType(scale.centerCrop);

    break;

    case 3:

    iv.setScaleType(scale.centerInside);

    break;

    case 4:

    iv.setScaleType(scale.fitCenter);

    break;

    case 5:

    iv.setScaleType(scale.fitEnd);

    break;

    case 6:

    iv.setScaleType(scale.fitStart);

    break;

    case 7:

    iv.setScaleType(scale.fitXY);

    break;

    }

    }

    });

    var alert = adb.create();

    alert.show();

    }

    return frame;

    LL.save();

  2. Jay M says:

    i forgot to mention the scale dialog is accessed by pressing the top left corner of the image

Leave a Reply

Your email address will not be published. Required fields are marked *