在codenameone中旋转fontImage

时间:2016-11-20 10:19:44

标签: codenameone

Image shareIcon = FontImage.createMaterial(FontImage.MATERIAL_REPLY, s);
shareIcon = shareIcon.rotate(180);
ShareButton shareButton = new ShareButton();
shareButton.setIcon(shareIcon);

如何在此处翻转图像? rotate方法什么都不做。

shai下面的答案在我的项目中不起作用

package com.mycompany.myapp;

import com.codename1.components.ShareButton;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.Dialog;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Button;
import com.codename1.ui.FontImage;
import com.codename1.ui.Image;
import com.codename1.ui.Toolbar;
import com.codename1.ui.layouts.BoxLayout;

public class MyApplication {

    private Form current;
    private Resources theme;

    public void init(Object context) {
        theme = UIManager.initFirstTheme("/theme");

        // Enable Toolbar on all Forms by default
        Toolbar.setGlobalToolbar(true);

        // Pro only feature, uncomment if you have a pro subscription
        // Log.bindCrashProtection(true);
    }

    public void start() {
        if (current != null) {
            current.show();
            return;
        }
        Form hi = new Form("Rotate");
        hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        Image shareIcon = FontImage.createMaterial(FontImage.MATERIAL_REPLY, new Button("").getUnselectedStyle(), 5);
        for (int i = 0; i < 360; i += 45) {
            ShareButton s = new ShareButton();
            s.setIcon(shareIcon.rotate(i));
            hi.add(s);
        }
        hi.show();
    }

    public void stop() {
        current = Display.getInstance().getCurrent();
        if (current instanceof Dialog) {
            ((Dialog) current).dispose();
            current = Display.getInstance().getCurrent();
        }
    }
    public void destroy() {
    }
}

如果你想看项目,那就是项目:

https://drive.google.com/open?id=0B8ATnICIY2S8OEtUU2lPSlFid3M

1 个答案:

答案 0 :(得分:0)

这对我有用:

Image shareIcon = FontImage.createMaterial(FontImage.MATERIAL_REPLY, new Button("").getUnselectedStyle(), 5);
for(int i = 0 ; i < 360 ; i += 45) {
    ShareButton s = new ShareButton();
    s.setIcon(shareIcon.rotate(i));
    hi.add(s);
}

enter image description here