Search code examples
javascriptxmlsapui5

how to create a horizontal scrollbar in SAP-ui5 using xml or Javascript


 <content>
            <ScrollContainer width="100%" horizontal="true" vertical="true" focusable="true">
            	<HBox id="idHBox"  width="99.9%"/>
            </ScrollContainer>
        </content>

this is my code in the XML site , HBox is a Parent element includes a SVG element but the Problem that it just show the vertical scrollbar but the horizontal not


Solution

  • What is the absolute size of your Image?

    Here is a small example.

    If you change the Image width, the horizontal scrollbar appears/disappears (e.g. width: "100%")

    <!DOCTYPE HTML>
    <html>
        <head>
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta charset="utf-8">
            <script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" 
                id="sap-ui-bootstrap"
                data-sap-ui-libs="sap.m" 
                data-sap-ui-theme="sap_belize"></script>
            <script>
                var app = new sap.m.App();
                var oImage = new sap.m.Image({
                    width: "3000px",
                    height: "300px",
                    src:"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/alphachannel.svg"        
                });
                
                var oHbox = new sap.m.HBox({
                    width: "100%",
                    items : [oImage]
                });
                
                var oScroll1 = new sap.m.ScrollContainer({
                    width:"100%",
                    focusable:true,
                    vertical:true,
                    horizontal:true,
                    content : [oHbox]
                });
    
                var page = new sap.m.Page({
                    content : [oScroll1]
                });
                
                app.addPage(page);
                app.placeAt('content')
            </script>
        </head>
        <body id="content" class="sapUiBody">
        </body>
    </html>