Reposition image in app

41 ビュー (過去 30 日間)
Johannes Hougaard
Johannes Hougaard 2021 年 11 月 3 日
コメント済み: Johannes Hougaard 2021 年 11 月 16 日
I am the author of a MATLAB app where I'd like to add a logo (as a uiimage) to the upper right corner of my UIFigure window.
When I resize my main app window (app.UIFIgure) the logo (app.Image) is not repositioned
I'd like it to keep the distance from the top and from the right side - how can you do that,
When I add a resizefcn to my UIFigure I get the warning message:
Warning: 'SizeChangedFcn' callback will not execute while 'AutoResizeChildren' is set to 'on'.
  1 件のコメント
Geoff Hayes
Geoff Hayes 2021 年 11 月 3 日
@Johannes Hougaard - have you tried using a Grid Layout Manager?

サインインしてコメントする。

採用された回答

Reshma Nerella
Reshma Nerella 2021 年 11 月 7 日
Hi,
I understand that you want to retain the figure at same place when the app is resized. There are a couple of ways to acheive this behavior.
1. Using the 'SizeChangedFcn' callback by 'AutoResizeChildren' is set to 'off'. The below snippet helps you to put the image in same place when app is resized.
function UIFigureSizeChanged(app, event)
position = app.UIFigure.Position;
app.Image.Position = [position(3)-17-100 position(4)-65-100 100 100];
end
For more information on managing resizable apps, refer to the following link: https://www.mathworks.com/help/matlab/creating_guis/managing-resizable-apps-in-app-designer.html
  1 件のコメント
Johannes Hougaard
Johannes Hougaard 2021 年 11 月 16 日
Thank you.
That kinda worked although it'll be preferable to me to keep the AutoResizeChildren to 'on' for all my other graphic elements.
It was feasible for this particular application though.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by