Image with ImageMode.Background
Visualizes the state of the control when the mode property is set to ImageMode.Background.
Z2UI5_CL_SMPC_APP_031
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_031- Source file
z2ui5_cl_smpc_app_031.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.Image- Demo kit sample
sap.m.sample.ImageModeBackground- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: image, sap.m, visualizes, state, html, verticallayout, grid, vbox, flexitemdata, text, hbox
Controls it builds
- sap.m.FlexItemData
- sap.m.HBox
- sap.m.Image
- sap.m.Text
- sap.m.VBox
- sap.ui.core.HTML
- sap.ui.core.mvc.View
- sap.ui.layout.Grid
- sap.ui.layout.VerticalLayout
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
Run it here
The sample running, in this page — the app on its own, with no editor over it.
Switch to Playground with this code
Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.
The ABAP
z2ui5_cl_smpc_app_031.clas.abap — 149 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords image sap.m visualizes state html verticallayout grid vbox flexitemdata text hbox
" @summary Visualizes the state of the control when the mode property is set to ImageMode.Background.
CLASS z2ui5_cl_smpc_app_031 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_031 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_navigated( ).
view_display( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
" fixed values of the original img JSONModel (/products/pic1, /products/pic3)
DATA(pic1) = `https://sdk.openui5.org/test-resources/sap/ui/documentation/sdk/images/HT-7777-large.jpg`.
DATA(pic3) = `https://sdk.openui5.org/test-resources/sap/ui/documentation/sdk/images/HT-6100-large.jpg`.
" the original's device-dependent image size (5em phone / 10em otherwise), expressed over the framework's device> model
DATA(size) = `{= ${device>/system/phone} ? '5em' : '10em' }`.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core`
" the sample's styles.css, injected via a core:HTML content attribute (see CAPABILITIES.md)
)->tag( n = `HTML` ns = `core`
" literal braces escaped \{ \} - the XMLView binding parser reads unescaped braces as a binding
)->a( n = `content` v = `<style>.imageContainer\{background-color:#A9EAFF\}</style>`
)->ele( n = `VerticalLayout` ns = `l`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `width` v = `100%`
)->ele( n = `content` ns = `l`
)->ele( n = `Grid` ns = `l`
)->a( n = `defaultSpan` v = `XL3 L3 M6 S12`
)->ele( n = `content` ns = `l`
)->ele( `VBox`
)->a( n = `alignItems` v = `Center`
)->ele( `Image`
)->a( n = `src` v = pic1
)->a( n = `mode` v = `Background`
)->a( n = `height` v = size
)->a( n = `width` v = size
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->end(
)->end(
)->tag( `Text`
)->a( n = `text` v = `Background covers the entire container`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->end(
)->ele( `VBox`
)->a( n = `alignItems` v = `Center`
)->ele( `Image`
)->a( n = `src` v = pic1
)->a( n = `mode` v = `Background`
)->a( n = `height` v = size
)->a( n = `backgroundSize` v = `5em 5em`
)->a( n = `backgroundPosition` v = `center`
)->a( n = `width` v = size
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->end(
)->end(
)->tag( `Text`
)->a( n = `text` v = `Center placed background`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->end(
)->ele( `VBox`
)->a( n = `alignItems` v = `Center`
)->ele( `Image`
)->a( n = `src` v = pic1
)->a( n = `mode` v = `Background`
)->a( n = `height` v = size
)->a( n = `backgroundSize` v = `2em 2em`
)->a( n = `backgroundRepeat` v = `repeat`
)->a( n = `width` v = size
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->end(
)->end(
)->tag( `Text`
)->a( n = `text` v = `Repeating background`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->end(
)->ele( `VBox`
)->a( n = `alignItems` v = `Center`
)->ele( `HBox`
)->a( n = `class` v = `imageContainer`
)->tag( `Image`
)->a( n = `src` v = pic3
)->a( n = `mode` v = `Background`
)->a( n = `height` v = size
)->a( n = `backgroundSize` v = `contain`
)->a( n = `backgroundPosition` v = `center center`
)->a( n = `width` v = `6em`
)->end(
)->tag( `Text`
)->a( n = `text` v = `The background adjusts its lower dimension in order to fit in the container`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->end( ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- Feed List Item — The Feed List Item provides a standard UI for 'feeds' where multiple users publish inform…
- Flex Box - Nested — Flex Boxes can be nested. Remember also that HBox and VBox are 'convenience' controls bas…
- Generic Tag with Different Configurations — Previews of the GenericTag control based on combinations of different sets of properties.
- KPI Tile — Shows KPI Tile samples that can contain header, subheader, key value, trend, scale, unit…
- Header Container - Horizontal Mode — The Header Container with horizontal layout. It provides horizontal scrolling on mobile d…
- Icon Tab Bar - Stretch Content Height — In this example, the IconTabBar height is stretched to the maximum height of the page con…
- Input - Value States — This example shows different input value states.
- Link - Emphasized — Usually you use an Object Identifier in the first column of a table. But if you need an a…
- List - Counter Indication — The counter of an item quickly shows how many detail entries are related, without having…
- List - No Data Indication — If the list is empty it indicates this state by displaying a message text.
- Message Box Initial Focus — Shows how to set initial focus to MessageBox button.
- Message Toast — The Message Toast displays the message text as an overlay to the current screen. It close…
On this page