首页 \ 问答 \ Libgdx ImageButton填充?(Libgdx ImageButton padding?)

Libgdx ImageButton填充?(Libgdx ImageButton padding?)

所以我对libgdx的ImageButton类有这个问题,问题是在android中图像没有扩展到按钮的完整大小,而在桌面它确实或者至少它做了更多,所以我不得不问是否有办法强制图像获取背景(按钮)的大小? 所以我可以试着在两个平台上做出相同的视觉效果。

下面是一个屏幕截图,后面的空格按钮是ImageButton ... 在此处输入图像描述

编辑:继承人代码....

    private void createButtons() {

        ImageButtonStyle ibs = new ImageButtonStyle(buttonD,buttonD_p,buttonD,bsIcon,bsIcon,bsIcon);
        buttonBS        = new ImageButton(ibs); // This is the backspace button

        ....
    }
    private void addButtonsToTable() {
        float pad = 1;
        float BUTTON_SIZE = this.BUTTON_SIZE - pad *3;
        table.top();
        table.center();
        table.add(buttonBS).width(BUTTON_SIZE).height(BUTTON_SIZE).pad(pad);
        table.row();

        ...
    }

so I have this problem with ImageButton class of libgdx, the problem is that in android the image doesnt expand to the full size of the button, and in desktop it does or at least it does more, so I have to ask if theres a way to force the image to get the size of the background(button)? so i can try to make an equal visualitation on both plataforms.

heres a screen shot, the back space button is the ImageButton... enter image description here

edit: heres the code....

    private void createButtons() {

        ImageButtonStyle ibs = new ImageButtonStyle(buttonD,buttonD_p,buttonD,bsIcon,bsIcon,bsIcon);
        buttonBS        = new ImageButton(ibs); // This is the backspace button

        ....
    }
    private void addButtonsToTable() {
        float pad = 1;
        float BUTTON_SIZE = this.BUTTON_SIZE - pad *3;
        table.top();
        table.center();
        table.add(buttonBS).width(BUTTON_SIZE).height(BUTTON_SIZE).pad(pad);
        table.row();

        ...
    }

原文:https://stackoverflow.com/questions/36962984
更新时间:2023-01-08 13:01

最满意答案

添加样式:

position: fixed;
left: 0
top: 0

应该帮助你。 它钉在屏幕顶部左上角的元素。


Adding styles:

position: fixed;
left: 0
top: 0

should help you. It nails element top top left corner of a screen.

相关问答

更多
  • 您的网站在IE7 / 8中运行良好 - 我没有看到问题。 此外,标记不应再用于布局。 当你在页面上有下拉菜单或模态UI时,你不应该使用溢出隐藏。 如果你需要溢出:隐藏为浮动清除目的,请使用.clearfix hack .cf:before, .cf:after { content: " "; /* 1 */ display: table; /* 2 */ } .cf:after { clear: both; } /** * For IE 6/7 only * Include ...
  • 设置display:inline-block而不是display:inline在第#206行的style.css中display:inline到以下规则 #menu li { display: inline-block; /* change this */ list-style: none; padding: 0.3em 1em; } Set display:inline-block instead of display:inline to following rule in your sty ...
  • 您可以通过绝对定位子菜单来防止这种情况。 .menu li ul {display: none; position: absolute; } 你也必须设置 .menu { position: relative; } 正如Tae在评论中所说的那样。 如果你不这样做,子菜单可能会设置在页面的左上角。 You can prevent that by positioning the sub menu absolute. .menu li ul {display: none; position: absolute ...
  • 添加样式: position: fixed; left: 0 top: 0 应该帮助你。 它钉在屏幕顶部左上角的元素。 Adding styles: position: fixed; left: 0 top: 0 should help you. It nails element top top left corner of a screen.
  • 您将事件附加到错误的元素。 尝试 $('.dropdown-menu').on('click', 'li a', function(e) { alert($(this).text()); }); 之前没有工作的原因是双重的 您试图使用#访问类。 它应该用a来完成. dropdownFloorplanGroups类本身就是li 。 您应该从父容器委派 var dropD = $('
    你可以通过使用CSS3的过渡效果来实现这一点,如下所示: li ul { opacity: 0; transition: opacity 1s linear 0s; -webkit-transition: opacity 1s linear 0s; } li:hover ul { opacity: 1; } 不需要脚本..只需删除你的脚本并仅在你的小提琴中应用这个CSS ...它可能有用.. 注意:如果从菜单中鼠标输出时不需要动画,则仅在悬停状态下使用过渡效果,如下所示:这 ...
  • 试试这个请包括这些