Matrix SAPUI5用按钮填充整个矩阵布局单元

Matrix SAPUI5用按钮填充整个矩阵布局单元,matrix,layout,sapui5,Matrix,Layout,Sapui5,我想用一个按钮填充整个MatrixLayoutCell,使其完全覆盖单元格。 CSS类会增加按钮高度,但布局会将其切断。 深蓝色部分是按钮所在的单元格。所以细胞接受高度 我的CSS代码: .myProductButton .sapMBtnInner{ background-color: #0080ff !important; border-color: #0000a0!important; background-image: none !importa

我想用一个按钮填充整个MatrixLayoutCell,使其完全覆盖单元格。

CSS类会增加按钮高度,但布局会将其切断。 深蓝色部分是按钮所在的单元格。所以细胞接受高度

我的CSS代码:

.myProductButton .sapMBtnInner{

      background-color: #0080ff !important;

      border-color: #0000a0!important;

      background-image: none !important;

      text-shadow: none !important;

      font-weight: bold !important;

      height: 200px!important;

}
“我的视图”中的代码片段:

        var row1 = new sap.ui.commons.layout.MatrixLayoutRow("row_1");
var cell1 = new sap.ui.commons.layout.MatrixLayoutCell("cell_1");
cell1.addContent(prod1);
cell1.setBackgroundDesign('Fill1');

row1.addCell(cell1);
row1.setHeight('200px');

matrix_cell1.addRow(row1);

prod_cell1.addContent(matrix_cell1);
我尝试了几件事,但都没有成功。 有人想到了如何在MatrixLayout中解决这个问题,或者我需要将布局更改为网格吗


谢谢你的提示

您可以将按钮的
宽度
属性设置为100%,以适合容器。 如果将
padding=“None”
设置为单元格,则单元格末尾将不存在空格

例如:

<layout:MatrixLayoutCell backgroundDesign="Fill1" padding="None">
   <Button text="Test Button" width="100%"/>
</layout:MatrixLayoutCell>

(对于XML视图,但属性相同,您需要相应地调用
setPadding()
setWidth()


关于按钮的高度:目前无法在MatrixLayout中拉伸按钮的高度。此外,我不建议更改按钮的高度-它具有标准化的响应高度。

正如@nistv4n所说,您可以将按钮的宽度设置为100%,并使用
填充:“无”删除单元格填充

要调整高度,可以向按钮添加样式类(可能已经这样做了):

prod1.addStyleClass(“myProductButton”);
并使用一手css展开高度并垂直对齐文本:

.myProductButton{
高度:200px;
填充:0;
}
.myProductButton.sapmbtniner{
身高:100%;
显示器:flex;
对齐项目:居中;
}
.myProductButton.sapmbtniner.sapmbtcontent{
宽度:100%
}
举个例子

但请注意,不建议在同一应用程序中使用sap.m和sap.ui.commons