ui5_Walkthrough_Step 34: Responsiveness响应式布局

一、基本概念

响应式布局(Responsiveness):网页或应用能够根据不同的设备屏幕尺寸和方向,自动调整其布局、内容和交互方式,以提供最佳的用户体验。

二、练习

2.1 webapp/view/InvoiceList.view.xml

XML 复制代码
<mvc:View
   controllerName="sap.ui5.walkthrough.controller.InvoiceList"
   xmlns="sap.m"
   xmlns:core="sap.ui.core"
   xmlns:mvc="sap.ui.core.mvc">
   <Table
      id="invoiceList"
      class="sapUiResponsiveMargin"
      width="auto"
      items="{ 
         path : 'invoice>/Invoices',
         sorter: [
            {
                path: 'ShipperName',
                group: true          
            },
            {
                path: 'Quantity',
                descending: true
            }
        ]
            }">
       <headerToolbar>
         <Toolbar>
            <Title text="{i18n>invoiceListTitle}"/>    <!-- 左侧标题 -->
            <ToolbarSpacer/>  <!-- 弹性间距,将后面的控件推到右侧 -->
            <SearchField 
               width="50%" 
               search=".onFilterInvoices"/>  <!-- 搜索事件处理函数 -->
         </Toolbar>
      </headerToolbar>
      <columns>
      <Column
				hAlign="End"
				minScreenWidth="Small"
				demandPopin="true"
				width="4em">
				<Text text="{i18n>columnQuantity}"/>
			</Column>
			<Column>
				<Text text="{i18n>columnName}"/>
			</Column>
			<Column
				minScreenWidth="Small"
				demandPopin="true">
				<Text text="{i18n>columnStatus}"/>
			</Column>
			<Column
				minScreenWidth="Tablet"
				demandPopin="false">
				<Text text="{i18n>columnSupplier}"/>
			</Column>
			<Column
				hAlign="End">
				<Text text="{i18n>columnPrice}"/>
			</Column>
		</columns>
      <items>
         <ColumnListItem
            type="Navigation"
				press="onPress" >
            <cells>
            <ObjectNumber number="{invoice>Quantity}" emphasized="false"/>
			   <ObjectIdentifier title="{invoice>ProductName}"/>
            <Text text="{path:'invoice>Status',formatter:'.formatter.statusText'}" />
            <Text text="{invoice>ShipperName}"/>
			   <ObjectNumber
						number="{
							parts: [{path: 'invoice>ExtendedPrice'}, {path: 'view>/currency'}],
							type: 'sap.ui.model.type.Currency',
							formatOptions: {
								showMeasure: false
							}
						}"
						unit="{view>/currency}"
						state="{= ${invoice>ExtendedPrice} > 50 ? 'Error' : 'Success' }"/>
            </cells>
        </ColumnListItem>  
      </items>
   </Table>
</mvc:View>

2.2 webapp\i18n\i18n.properties

XML 复制代码
# App Descriptor
apptitle=SAPUI5 Walkthrough Step Step 34: Responsiveness
appTitle=SAPUI5 Walkthrough Step Step 34: Responsiveness  
appDescription= Descriptor for Applications

homePageTitle=PageTitle
panelTitle1=PanelTitle

# Invoice List
ButtonText=Click me
Msg=Hello {0}
inputText= Step Step 34: Responsiveness  
textDesc=Hello
openDialogButtonText=Dialogs and Fragments
helloDialogMsg =helloDialoginf
dialogCloseButtonText=Ok
invoiceListTitle=Invoices
invoiceStatusA=New
invoiceStatusB=In Progress
invoiceStatusC=Done
columnQuantity=Quantity
columnName=Name
columnSupplier=Supplier
columnStatus=Status
columnPrice=Price
# Detail Page
detailPageTitle=Walkthrough - Details
ratingConfirmation=You have rated this product with {0} stars

# Product Rating
productRatingLabelInitial=Please rate this product
productRatingLabelIndicator=Your rating: {0} out of {1}
productRatingLabelFinal=Thank you for your rating!
productRatingButton=Rate

三 、运行结果

http://localhost:8080/webapp/index.html# 默认显示

浏览器打开开发者工具,切换单元素页签,选择设备iphone 12 pro 如下

相关推荐
狮子座的男孩4 天前
html+css基础:31、响应式布局(媒体类型,媒体特性,运算符,常用阈值)
前端·css·经验分享·html·响应式布局·媒体类型/特性·常用阈值
FungLeo8 天前
成为全栈·Vue 管理后台篇·可折叠侧栏与移动抽屉:后台导航的响应式实现
前端·javascript·vue.js·侧边栏·响应式布局·无障碍·移动端导航
DsirNg2 个月前
断点不该认识设备:组件布局的容器状态治理
css·前端工程化·组件化·响应式布局·css grid·设计系统·container queries
DsirNg2 个月前
响应式的真正输入:为组件重新定义可用空间
css·flexbox·grid·前端架构·响应式布局·设计系统·container queries
贾伟康3 个月前
【句匠|16】HarmonyOS ArkTS 多设备布局实战:适配手机、平板和 PC/2in1 的窗口变化
harmonyos·arkts·arkui·响应式布局·多设备适配
贾伟康3 个月前
【口算王|16】HarmonyOS ArkTS 多设备布局实战:适配手机、平板和 PC/2in1 的窗口变化
harmonyos·arkts·arkui·响应式布局·多设备适配
贾伟康3 个月前
【时光清单|16】HarmonyOS ArkTS 多设备布局实战:适配手机、平板和 PC/2in1 的窗口变化
harmonyos·arkts·arkui·响应式布局·多设备适配
贾伟康3 个月前
【天体运行模拟|16】HarmonyOS ArkTS 多设备布局实战:适配手机、平板和 PC/2in1 的窗口变化
harmonyos·arkts·arkui·响应式布局·多设备适配
m0_749690233 个月前
【寻迹校园 HarmonyOS NEXT 实战 37】一套 ArkUI 适配四档宽度:sm、md、lg、xl 响应式 Shell 实战
华为·harmonyos·arkui·navigation·响应式布局·多设备适配
贾伟康3 个月前
【知律|16】HarmonyOS ArkTS 多设备布局实战:适配手机、平板和 PC/2in1 的窗口变化
harmonyos·arkts·arkui·响应式布局·多设备适配