Hi Micheal,
Pleas see the below code.
View:
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="testing.imageXml" xmlns:html="http://www.w3.org/1999/xhtml"> <Page title="Image"> <content> <Image id="img1" alt="alttextimage" src="images/img1.jpg" /> </content> </Page></core:View>
Controller:
onBeforeRendering: function() { this.getView().byId("img1").addStyleClass("myimage"); },
Index.html
<script src="resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m,sap.ui.commons" data-sap-ui-theme="sap_bluecrystal"> </script> <!-- only load the mobile lib "sap.m" and the "sap_mvi" theme --> <script> sap.ui.localResources("testing"); var app = new sap.m.App({initialPage:"idhome1"}); var page = sap.ui.view({id:"idhome1", viewName:"testing.imageXml", type:sap.ui.core.mvc.ViewType.XML}); app.addPage(page); app.placeAt("content"); </script>
<style> .myimage{float:right !important; width:300px; height:200px;} </style>
Output :
Regards,
KK