uitable: text-alignment with HTML

조회 수: 5 (최근 30일)
M.
M. 2014년 3월 26일
댓글: Walter Roberson 2023년 1월 19일
Hello everybody!
To customize uitbales in Matlab I used the solution posted in:
which works perfectly.
Additionally, I would like to align each cell content (strings) to the center of the cell. To do so I tried changing:
colText('Blue text', 'blue'), ...
to
colText('<HTML><p style="text-align:center">Blue text</p></HTML>', 'blue')
But it does not show any effect.
Can you tell me how it is possible to change the text alignment in the cells using the suggested code snippet from the posted link and maybe give an example?
Thank you very much in advance!

답변 (2개)

Walter Roberson
Walter Roberson 2014년 3월 26일
편집: Walter Roberson 2023년 1월 19일
style attributes and css are newer than the HTML that is supported. Use the HTML CENTER tag instead.
  댓글 수: 2
M.
M. 2014년 3월 26일
편집: M. 2014년 3월 28일
Thank you for your answer. Do you mean
colText('<html><center>test</center></html>', 'blue'), ...
?
Unfortunatelly that doesn't work either =/
Walter Roberson
Walter Roberson 2023년 1월 19일
Note: in the time since this question was originally asked, uifigure() were added. uitable() that exist within uifigure() have additional formatting possibilities

댓글을 달려면 로그인하십시오.


Prof. X
Prof. X 2023년 1월 19일
편집: Prof. X 2023년 1월 19일
Use this as reference. This centers the text, makes the background red, and changes the font color to white:
uitable('data',{'<html><tr><td width=9999 style="color:White;background-color:#FF0000;text-align:center">X'})

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by