- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试拥有一个与其父级一起缩放的 ImageView。我搜索了所有我能找到的 StackOverflow 帖子,这是我尝试过的:
taggedImage.setPreserveRatio(true);
//taggedImage.fitWidthProperty().bind(
// Bindings.min(imagePane.widthProperty(), imagePane.widthProperty()));
//taggedImage.fitHeightProperty().bind(
// Bindings.min(imagePane.heightProperty(), imagePane.heightProperty()));
taggedImage.fitWidthProperty().bind(imagePane.widthProperty());
taggedImage.fitHeightProperty().bind(imagePane.heightProperty());
我也尝试过注释行,这些方法的问题是当 imageview 绑定(bind)到父级时,父级只能放大而不能缩小。因此,如果增加窗口的大小,图片就会变大。如果您再次减小图片尺寸,它不会减小图片尺寸。在此示例中,imagePane 是 StackPane。我也尝试过 borderFrame。同样,我尝试过使用 Pane 作为父级。这样,图像就成功地按比例放大和缩小了。但是,如果图像与 Pane 的大小不完全匹配,则图像不会居中并且始终位于 Pane 的左上角。
场景树: https://gyazo.com/45e0daebbfd98dfd3446185d21eb91ee
值(value)观:
顶部网格:
https://gyazo.com/f48ebb39f48d876a02d44792a73eaad4
较低级别的网格 Pane :
https://gyazo.com/3399d9f3ab00e8babd36ee3b0e3b27ba
边框 Pane :
https://gyazo.com/51c24f8de50ae3865a299fdddf3a1490
图片 View :
https://gyazo.com/7dfc1071d2b516a83baed301596be2b9
请注意,我在这里尝试使用边框而不是之前使用的边框。但是,无论哪个对象是 ImageView 的父对象,结果都是一样的。
最佳答案
已解决。我一直在搞乱并找到了解决办法。这不是很直观,但对我有用:我将图像留在 borderframe 内,然后在 Java 代码中,我在与图像相同的网格 Pane 部分创建了一个 Pane 。然后我将 imageview 的宽度和高度绑定(bind)到 Pane 。然后,图像的居中和缩放都是正确的。这是我所做的:
imageView.setPreserveRatio(true);
Pane pane = new Pane();
testGridPane.add(pane, 1, 1);
imageView.fitWidthProperty().bind(pane.widthProperty());
imageView.fitHeightProperty().bind(pane.heightProperty());
关于java - JFX 将图像向上和向下缩放到父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50918108/
我有一个带有 H264 身份验证的 RTSP 流的 URL - MPEG-4 第 10 部分编解码器。 Lik 看起来像这样:rtsp://login:pass@xxx.xxx.xxx.xxx:557
我正在开发移动应用程序。现在,我将访问 token 放在SharedPrefences上。我想问一下SharedPrefences上的存储访问 token 是否安全?如果没有,最好的做法是在哪里放置访
一个 UITableView,它有 20 行的 UITableViewCell,每一行都有一个按钮,单击按钮我想将 UITableViewCell 放到 UITableView 的底部。 是否有任何委
我有这样的代码。我删掉了所有的细节,但是这个文本区域会在按下按钮后发生变化,而它所做的只是改变了文本区域。没有添加滚动。我什至尝试将滚动策略设置为始终,但它返回错误。此面板将添加到另一个带有 Bord
我想在 NSString 中有 src="字符。 但我不能这样做,因为 "是 Objective C 的一部分。 我想这样做: NSString * name = [ [NSString alloc]
非常新手的问题,我是 html 的新手,特别是 highcharts 的东西。所以首先,我制作了这个 test.php 来显示图表。 Highcharts Exampl
如何将我的 fab 放在我的 fragment 上?请帮助我收到错误,例如。 android.view.InflateException: Binary XML file line #13: Erro
我已经完成了一个unity的迷你游戏,名为“penguins_test”。我导出了 2 个文件: penguins_test.html penguins_test.unity3d 现在,我想使用 Go
有谁知道如何将 uiviewcontroller(或只是 View )添加到 cocos2d 层上? 最佳答案 是这样的: [[CCDirector sharedDirector].view addS
我知道您可以采取一些技巧,将 HTML 元素放在 Silverlight 应用程序的顶部,但这无法全屏显示。有没有办法在 Silverlight 应用程序中显示 html 页面? 最佳答案 http:
从 Golang 教程中我不清楚如何将 Golang 代码放到 Github 以便以后能够从 Github 将该代码作为包导入。 这是来自 Golang 教程 http://golang.org/do
我围绕 Pygame 构建了我的整个游戏,并想把它放到 Steam 上。最后我了解到我需要 OpenGL 支持才能运行 Steam 的叠加层。初始化显示的代码: screen = pygame.dis
我需要将已编译的 apk 文件复制到作业 artifats,以便在成功时能够直接从作业页面下载它。 现在我已经在文件夹 build/apk/MyProject-release.apk 中编译了 apk
我愿意在本地和 Heroku 上处理不同的设置。所以我在 settings.py 的末尾使用了这个导入: try: from local_settings import * except Im
我是安卓新手。这个问题是我尝试使用 Android 应用程序和 Web 服务的步骤中的一个阶段。我之前问过一个问题,在这里:Fail to connect android to web service
我是 Git 新手。我刚刚在我的计算机上创建了一个 Git 存储库。现在我想将该存储库连接到网站 (GitHub) 并将我的代码推送到那里。 我该怎么做?我有点熟悉......我必须以某种方式将在线代
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: How to use an existing database with an Android applic
如何在浏览器选项卡上显示标签名称? :( 帮我我想将我的标签显示为选项卡,有什么技巧吗? 技巧 - ABC 技巧 - 最佳答案 是的,您可以使用 在浏览器选项卡中显示标签名称 示例标题代码:
我需要 Tomcat 上的 JAX-WS 运行时。 把“jax-ws/lib/*”放到“tomcat/lib”里可以吗? 如果将 jax-ws/lib 放入 tomcat/lib,是否需要 Tomca
我已经在Win10系统中安装了hadoop-2.5.2和eclipse neon.1a,但是我把“hadoop-eclipse-plugin-2.5.2.jar”放到/eclipse/plugins后
我是一名优秀的程序员,十分优秀!