Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:14:44+00:00 2026-06-14T20:14:44+00:00

I am creating a simple app with an image. I create the app like

  • 0

I am creating a simple app with an image. I create the app like so:

function createApplication(){
  var app = UiApp.createApplication().setTitle("My Simple App");
  mainImage = app.createImage("URL TO IMAGE");
  app.add(mainImage);
  return(app);
}

This puts the image to the top left of the screen. Can someone show me how to center the image ?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:14:44+00:00Added an answer on June 14, 2026 at 8:14 pm

    You can use setStyleAttribute() and refer to some CSS documentation

    try it like this for example (I’m really not an expert in CSS so don’t blame me if it is inelegant 😉

    function testImage(){
      var app = UiApp.createApplication().setTitle("My Simple App").setHeight('700').setWidth('900');
      mainImage = app.createImage("https://dl.dropbox.com/u/211279/Time-change-clock_animated_TR80.gif")
      .setStyleAttribute('position','relative').setStyleAttribute('left','50%').setStyleAttribute('top','50%')
      app.add(mainImage);
      ss=SpreadsheetApp.getActive()
      ss.show(app)
    }
    

    Note : You can also position your image using PX(pixels) instead of % and, as you noticed, I tested this in a spreadsheet UI.


    EDIT : and here is a version using pixels and Bryan’s suggestion for CSS styling, more compact and with a syntax that approaches the original CSS method (thx again) :

    var _imgCSS = {'position':'relative', 'left':'200PX', 'top':'200PX'}
    
    function testImage(){
          var app = UiApp.createApplication().setTitle("My Simple App").setHeight('500').setWidth('500');
          var mainImage = app.createImage("https://dl.dropbox.com/u/211279/Time-change-clock_animated_TR80.gif")
          .setStyleAttributes(_imgCSS)
          app.add(mainImage);
          ss=SpreadsheetApp.getActive()
          ss.show(app)
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating a simple Flex 4.6 App, where the creationComplete-handler looks like this: protected
I'm creating a simple app with a table and an Add row button. Using
I am creating simple app on Silverlight 4. In folder of View I have
I am creating a simple web app. There is a <video> element on the
my question is simple i think. I am creating a really simple app which
Good morning, A bit of background might help. I'm creating a very simple app
I'm currently learning rails by creating a simple project management app. I've gotten to
I am creating an app that will point a simple arrow in the direction
I'm currently creating my first android app and I've a simple class 'Player' I
I needed some suggestion from ya'll.. I'm creating a video image viewer app for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.