What causes a discrepancy in the display of images between the GUI Builder, the device, and the Codename One Simulator?

Currently, I am in the process of designing my app's UI using the GUI Builder. I have created a new Form and defined a style as follows:

FinishFlagIcon {
background-image: url(pics/FinishFlag.png);
cn1-background-type: cn1-image-scaled-fit;
cn1-source-dpi: 320;
font-size: 11.9mm; 
}

Upon applying this style to a label, it displays correctly within the GUI Builder. https://i.sstatic.net/J8UTw.png

However, when I run the project on the simulator, the icon does not appear anymore. https://i.sstatic.net/0UqaK.png

I also attempted using a Scaled Label with the FinishFlag icon from the res file, which showed up in the GUI Builder but failed to display on the simulator. No error messages were logged indicating any issues with the file.

Please note that all related png files are stored in the res/myCustomTheme.css folder along with their respective subfolders (ranging from low to hd resolution). The src/theme.res file includes the necessary images, per Shai's advice: https://i.sstatic.net/4GMjU.png

How can I ensure the picture appears on the simulator?

Edit: Upon manually coding the UI by adding a labeled component with the specified UIID to the central region of a BorderLayout, the icon did not show unless 3 spaces or more were added to the Label. This behavior strikes me as unusual, is it intentional?

Update September 13th, 2017: Upon building the app and testing it on an actual Android device, the labels now appear. https://i.sstatic.net/qhMer.png

Update September 15th, 2017: To address the issue of components not displaying, following the accepted answer, one must remove the top or bottom constraint of the non-visible component and set it to auto (by clicking on the lock) to allow ample space for the components. After setting the bottom constraint of the progress bar and labels to "auto", the expected result finally appeared on the simulator:

https://i.sstatic.net/31xDA.png

Any assistance would be greatly appreciated,

Answer №1

It appears that the culprit in your issue lies within the layout insets rather than the images used. If you take a closer look, you'll notice that none of the lower components are appearing on the simulator, such as the "progression" label and the three zeroes.

While I cannot directly view the constraints set for the flags or zeroes labels, it is clear that the "progression" label has fixed insets both at the top and bottom. This rigidity could be causing a zero height if there isn't adequate space allocated. Consider making either the top or bottom insets flexible by setting them to "auto."

To further troubleshoot, switch the simulator to the desktop theme so you can adjust the window size and observe how the form adapts to different dimensions.

You can also confirm this suspicion by overriding the layoutContainer() method of the form and examining the height of your flag label:

public void layoutContainer() {
   super.layoutContainer();
   System.out.println("finishflag height: "+gui_FinishFlag.getHeight());
}

Answer №2

There may not be a clear-cut solution for this issue, so perhaps Steve can provide some insight, but here is what appears to be happening.

In your project, there are two resource files: theme and theme.css.

The images referenced in theme.css display correctly for your styles. However, because the loading process only recognizes theme and not theme.css, these images are not recognized by the simulator as they belong to a different file that the theme res file is not aware of.

The GUI builder likely scans all available res files, hence allowing you to include them which could lead to errors. Below are some workarounds you can consider:

  • Load theme.css and exclude theme - remember to set the inheritNativeThemeBool flag and avoid using the designer tool if you choose this option

  • Utilize the designer tool to directly load the images instead of relying on CSS

  • Explicitly open and load the css res file using Resources.open and specifically assign it to the Form

  • Explicitly open and load the css res file using Resources.open and designate it as the global resource file

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to display a vertical scrollbar within a select box

I'm currently working with an Angular select box and I'm looking to display a scroll bar if there are more than 5 data entries. <select class="form-control" data-ng-model='projectListData.appVersion' ng-selected ng-options="v.versio ...

Mystery factor triggering the appearance of scrollbar as the window is resized to a specific width threshold

I'm facing a rather peculiar problem. I'm currently in the process of creating a webpage tailored for an iPhone screen resolution of: width: 640; height: 960; However, there seems to be a mysterious hidden element that is extending the width of ...

What is the most efficient way to modify the color of an ID within a list?

My website features a <ul> element with four nested <li> elements, each belonging to the class .list. In order to give them different colors, I assigned unique IDs to each one - <id="list1">, <id="list2">, <id="list3">, and &l ...

Is there a way to display a specific item in the breadcrumbs with a unique color that contrasts with the other items?

I have created a breadcrumb using CSS and HTML, but I want to add a unique style to one of the items in the list without using hover effects. I attempted to apply a different class with a background color but it didn't work as expected. Does anyone h ...

When the browser window is minimized, the @media CSS will wrap to the bottom line

When the browser has a standard resolution, the layout looks like this: https://i.sstatic.net/tNR6X.png However, on smaller screens, it appears like this: https://i.sstatic.net/U3RnZ.png Is there a way to adjust the positioning of these blocks using @m ...

Is there a way to fix the issue of ContextMenu not appearing at the right position within a scrollable

I have a div within an iframe that needs to display a context menu when right-clicked. The div's length may exceed the visible area, making it scrollable. However, the issue I am facing is that the context menu appears in a different position than whe ...

Limit the radius to only apply on big screens using tailwind css

Is there a way to apply border radius to an image only on larger screens and maintain straight edges on smaller screens? I'm working with Nextjs and Tailwind CSS. ...

Looking for a solution to fix parallax images appearing blurred or pixelated on an iPhone? Seeking guidance on

Currently, I'm facing an issue with my website. The background images appear pixelated on iPhone screens. This is the HTML code I am using: <div class="parallax img-overlay3" style="background-image:url(img/pictures/food02.jpg)" data-stellar-bac ...

Tips for ensuring two blocks, each containing two pairs, remain next to each other within a div without being separated

As a newcomer to HTML/CSS and Liquid, I am exploring the creation and styling of custom blocks on a Product Page. My goal is to display these custom blocks in pairs within a single div. The current code structure I have implemented functions well, with on ...

How can I deactivate Bootstrap specifically within a certain block of content?

Is there a way to deactivate Bootstrap within a specific section? I want the styles from Bootstrap's CSS file to be overridden inside this div. ...

Steps to create a persistent bottom modal with scrollable content

I'm currently using Bootstrap 4.6 within my Angular application. I have implemented a modal that expands to full-screen on mobile devices, and now I want to add a fixed footer with scrolling body content. I've attempted to adjust the height of t ...

disregard the background styling applied to the parent element with the class of `.wrapper`

I am completely new to all of this, so please bear with me. Here's my current situation: So, I've set a background image for the entire body of my website. I have a div called .wrapper that I use on all of my pages. Its main purpose is to keep m ...

WordPress Website Failing to Recognize @import Rule

Not really sure what's going on with the site layout, but it seems that in the style.css file, right at the beginning of the file, these two lines are not being recognized: @import "css/reset.css"; @import "css/layout.css"; It's strange because ...

Tips for avoiding tagline text overlapping with other content

I'm facing a dilemma with my Bootstrap template where my tagline overlaps all other content on the page. When I scroll down, the text lays over my logo and navbar, creating a messy look especially on smaller screens. Despite trying to adjust the z-in ...

A guide on displaying containers with jQuery and CSS

Looking to create a smiley survey using only Front-End technologies. Once a radio button is selected, the associated content should appear for comments. Currently, I have set up my CSS with display: none. I attempted to implement this functionality using ...

What is the best way to ensure an image is shown in full screen exclusively on mobile devices?

My goal is to have two different site templates, one for desktop (which is already good) and one for mobile. For the mobile template, I want it to display only an image that fills the entire screen. The image should take up all the available space in term ...

Alignment problem detected in Firefox and Safari, but works perfectly in Chrome

Currently dealing with a CSS problem on my website that is only appearing in Safari and Firefox, while Chrome displays it correctly. The images are not positioning correctly and are stacking instead of being placed in each box as intended. I've expe ...

How to reference ASP.NET Core Blazor static files within a css asset

The latest enhancement in .NET 9.0 known as MapStaticAssets is designed to improve the deployment of static asset files. It addresses issues like outdated assets in browsers and allows for the delivery of compressed versions of assets. To include a static ...

MUI Gradient Tracked Button

Take a look at this Codepen example I created. It showcases a hover effect where the gradient follows the mouse cursor. In order to achieve this effect, I have defined two CSS variables - --x and --y, to keep track of the mouse position on the button. The ...

Is it not feasible to place a well within a column using Bootstrap?

Would like to place a .well div (or a button, whichever works best) within the designated green area shown in this image: here Here is the code I currently have: <div class="container-fluid"> <div class="row row1" style=&q ...