title: Codename One: Style Toolbar with Image
body: <p>In my app, I can't figure out how to properly style the toolbar with my logo image.</p>
  
  <p>What I want to make it look like is pretty much like the Toolbar from the "Sport1" App.
  <a href="http://a3.mzstatic.com/eu/r30/Purple60/v4/92/e6/2e/92e62e49-187f-c350-78c9-36c3401f65f2/screen1136x1136.jpeg" rel="nofollow noreferrer">Example</a></p>
  
  <p>So I need the back Command on the left side of the toolbar, my logo in the middle from a MultiImage out of the resource and on the right another command.</p>
  
  <p>Also, I'd like to let the Toolbar get smaller with scrolling.
  What I have tried so far:</p>
  
  <pre><code>    res_theme = r;
      Form f = new Form(" ", new BoxLayout(BoxLayout.Y_AXIS));
      logo = res_theme.getImage("Logo_Gema_vertikal.png");
      f.getToolbar().getTitleComponent().setUIID("toolbar_image");
      Style stitle = f.getToolbar().getStyle();
      stitle.setBgTransparency(0);
      stitle.setBgImage(logo);
      stitle.setBackgroundType(Style.BACKGROUND_IMAGE_ALIGNED_CENTER);
      stitle.setPaddingUnit(Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS);
      stitle.setPaddingTop(5);
  </code></pre>
  
  <p>So, this looks good the way it is. I dont actually need a Title, thats why I do </p>
  
  <pre><code>Form f = (" ", ...);
  </code></pre>
  
  <p>If I don't add a title to the form, the toolbar gets very small and squeezes the background Image from the toolbar. The centered logo from the toolbar is just for styling reasons there, it does not need to have a command. Is there a way to leave out the Title? I now have set it to completely transparent, but for me this is just a work-around.</p>
  
  <p>Also, I guess rather than setting the logo as background with a centered alignment, I think it would be better to add it to the title section as Image, but I don't know if this is better or how to do it.</p>
  
  <p>Now, I also want to make the Toolbar get smaller when scrolling down. I found kind of a example code in the Codename One Toolbar Documentation, but it does not work out for me, since the background Image gets removed.</p>
  
  <p>This was the code for the scrolling Animation:</p>
  
  <pre><code>    ComponentAnimation title = f.getToolbar().getTitleComponent().createStyleAnimation("Title", 200);
      f.getAnimationManager().onTitleScrollAnimation(title);
  </code></pre>
  
  <p>In the example, it worked. With my toolbar it does not, I have no clue why. I also can't see, where the size of the "after scrolling toolbar" is set.</p>
  
  <p>Can I add there an Image as well? Kinda like one toolbar before scrolling with my logo, then while scrolling it transforms into a smaller one with only a textlogo image?</p>
  
  <p>Here is my whole code what I have tried to make it work:</p>
  
  <pre><code>Form f = new Form(" ", new BoxLayout(BoxLayout.Y_AXIS));
      logo = res_theme.getImage("Logo_Gema_vertikal.png");
      f.getToolbar().getTitleComponent().setUIID("toolbar_image");
      Style stitle = f.getToolbar().getStyle();
      stitle.setBgTransparency(0);
      stitle.setBgImage(logo);
      stitle.setBackgroundType(Style.BACKGROUND_IMAGE_ALIGNED_CENTER);
      stitle.setPaddingUnit(Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS);
      stitle.setPaddingTop(5);
      f.add(new SpanLabel("asdasdasdasd");
      ComponentAnimation title = f.getToolbar().getTitleComponent().createStyleAnimation("Title", 200);
      f.getAnimationManager().onTitleScrollAnimation(title);
      f.show();
  </code></pre>