但是我在MaterialButton中找不到任何属性来将app:icon的重力设置为顶部。 我只能将其设置为开始或结束。 有没有办法在不将Vertical LinearLayout与ImageView和TextView一起使用的情况下设置创建类似按钮的方法?
答案 0 :(得分:1)
您可以为此使用createTable = () => {
const rows = [];
const { tableData } = this.state;
tableData.forEach((row, i) => {
const cell = [];
for (let idx = 0; idx < 8; idx++) {
cell.push(
<td
contenteditable='true'
onChange={e => this.handleChangeTable(e, i, idx)} //to incorporate event with other params
key={`${i}-${idx}`}
id={idx} //cell no
></td>
);
}
rows.push(
<tr key={i} id={i}>
<img
id={i}
onClick={() => this.removeRow(i)}
src={Image}
alt={cell}
/>
{cell}
</tr>
);
});
return rows;
};
属性
注意:这不仅限于您可以使用的MaterialButton 在TextViews和其他视图上也可以
示例代码:
removeRow = (rowIndex) => {
const{ tableData } = this.state;
tableData.splice(rowIndex, 1);
this.setState({ tableData });
console.log(`removed ${rowIndex}`);
};
答案 1 :(得分:1)