当前位置: 首页>>代码示例>>Java>>正文


Java UIView类代码示例

本文整理汇总了Java中org.robovm.apple.uikit.UIView的典型用法代码示例。如果您正苦于以下问题:Java UIView类的具体用法?Java UIView怎么用?Java UIView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UIView类属于org.robovm.apple.uikit包,在下文中一共展示了UIView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createView

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public UIView createView(String name, Map<String, String> attrs, UIView parent) {
    if(name.equals("view")) {
        name = attrs.get("class");
    }
    UIView result = null;
    try {
        result = viewFactory.createView(name, attrs, this.actionTarget);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | NoSuchMethodException| InvocationTargetException e) {
        e.printStackTrace();

        Foundation.log(String.format("Warning!!!!! Could not initialize class for view with name %s. Creating UIView instead: %s", name, e));
        try {
            result = viewFactory.createView("UIView", attrs, this.actionTarget);
        } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | NoSuchMethodException| InvocationTargetException e1) {
            e1.printStackTrace();
        }
    }
    return result;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:20,代码来源:LayoutInflater.java

示例2: inflate

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public UIView inflate(NSURL url, UIView rootView, boolean attachToRoot) {
    UIView result = null;
    NSDate methodStart = new NSDate();

    try {
        Document xml = ResourceManager.getCurrent().getXmlCache().getXML(url);
        result = inflate(xml, rootView, attachToRoot);

        double timeIntervalSince = NSDate.now().getTimeIntervalSince(methodStart);
        Foundation.log(String.format("Inflation of %s took %.2fms", url.getAbsoluteString(), timeIntervalSince));

    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:18,代码来源:LayoutInflater.java

示例3: findAndScrollToFirstResponder

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public static UIView findAndScrollToFirstResponder(UIView view) {
    UIView result = null;
    if(view.isFirstResponder()) {
        result = view;
    }

    for (UIView subView : view.getSubviews()) {
        UIView firstResponder = findAndScrollToFirstResponder(subView);
        if(firstResponder != null) {
            if(view instanceof UIScrollView) {
                UIScrollView sv = (UIScrollView) view;
                CGRect r = view.convertRectFromView(firstResponder.getFrame(), firstResponder);
                sv.scrollRectToVisible(r, false);

                result = view;
            } else {
                result = firstResponder;
            }
            break;
        }
    }

    return result;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:25,代码来源:UIViewLayoutBridgeUtil.java

示例4: measureChild

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public static void measureChild(UIView view, UIView child, LayoutMeasureSpec parentWidthMeasureSpec,
                                double widthUsed, LayoutMeasureSpec parentHeightMeasureSpec, double heightUsed) {

    MarginLayoutParams lp = (MarginLayoutParams) UIViewLayoutUtil.getLayoutParams(child);
    UIEdgeInsets lpMargin = lp.getMargin();
    UIEdgeInsets padding = UIViewLayoutUtil.getPadding(view);

    double leftRightPaddingMargin = padding.getLeft() + padding.getRight() + lpMargin.getLeft() + lpMargin.getRight();
    double topBottomPaddingMargin = padding.getTop() + padding.getBottom() + lpMargin.getTop() + lpMargin.getBottom();

    LayoutMeasureSpec childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, leftRightPaddingMargin + widthUsed, lp.getWidth());
    LayoutMeasureSpec childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, topBottomPaddingMargin + heightUsed, lp.getHeight());

    //Foundation.log(String.format("Measure child -> %s", UIViewLayoutUtil.getIdentifier(child)));

    UIViewLayoutUtil.measure(child, childWidthMeasureSpec, childHeightMeasureSpec);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:18,代码来源:UIViewViewGroupUtil.java

示例5: addView

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public static void addView(UIView parent, UIView child, int index, LayoutParams lp) {
    if(!isViewGroup(parent)) {
        throw new UnsupportedOperationException("Views can only be added on ViewGroup objects");
    }

    if(!UIViewLayoutUtil.checkLayoutParams(parent, lp)) {
        if(lp != null) {
            lp = UIViewLayoutUtil.generateLayoutParams(parent, lp);
        }
        if(lp == null || !UIViewLayoutUtil.checkLayoutParams(parent, lp)) {
            lp = UIViewLayoutUtil.generateDefaultLayoutParams(parent);
        }
    }

    UIViewLayoutUtil.setLayoutParams(child, lp);

    if(index == -1) {
        parent.addSubview(child);
    } else {
        parent.insertSubview(child, index);
    }
    UIViewLayoutUtil.requestLayout(parent);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:24,代码来源:UIViewViewGroupUtil.java

示例6: findMostCommonAncestorOfView

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
/**
 * Finds the most common ancestor of two views.
 */
protected UIView findMostCommonAncestorOfView(UIView view1, UIView view2) {
    NSMutableArray<UIView> path1 = new NSMutableArray<>();
    NSMutableArray<UIView> path2 = new NSMutableArray<>();

    UIView n1 = view1;
    while(n1 != null) {
        path1.add(n1);
        n1 = n1.getSuperview();
    }

    UIView n2 = view2;
    while(n2 != null) {
        path2.add(n2);
        n2 = n2.getSuperview();
    }

    UIView result = null;
    while(path1.last() != null && path1.last().isEqual(path2.last())) {
        result = path1.last();

        path1.remove(path1.size() - 1);
        path2.remove(path2.size() - 1);
    }
    return result;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:29,代码来源:ViewAssertsTest.java

示例7: setUp

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Before
public void setUp() {
    LayoutBridge bridge = new LayoutBridge(new CGRect(0, 0, 100, 100));

    LayoutInflater inflater = new LayoutInflater();
    UIView inflatedView = inflater.inflate("test/framelayout_gravity.xml", bridge, true);

    parent = UIViewLayoutUtil.findViewById(inflatedView, "parent");

    leftView = UIViewLayoutUtil.findViewById(inflatedView, "left");
    rightView = UIViewLayoutUtil.findViewById(inflatedView, "right");
    centerHorizontalView = UIViewLayoutUtil.findViewById(inflatedView, "center_horizontal");

    leftCenterVerticalView = UIViewLayoutUtil.findViewById(inflatedView, "left_center_vertical");
    rightCenterVerticalView = UIViewLayoutUtil.findViewById(inflatedView, "right_center_vertical");
    centerView = UIViewLayoutUtil.findViewById(inflatedView, "center");

    leftBottomView = UIViewLayoutUtil.findViewById(inflatedView, "left_bottom");
    rightBottomView = UIViewLayoutUtil.findViewById(inflatedView, "right_bottom");
    centerHorizontalBottomView = UIViewLayoutUtil.findViewById(inflatedView, "center_horizontal_bottom");
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:22,代码来源:FrameLayoutGravityTest.java

示例8: testRemoveChildren

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Test
public void testRemoveChildren() throws Exception {
    NSMutableArray<UIView> views = new NSMutableArray<>(24);

    for (int i = 0; i < 24; i++) {
        UIView view = createViewWithText(String.valueOf(i + 1));
        views.add(view);
        group.addView(view);
    }

    for (int i = views.size() - 1; i >= 0; i--) {
        UIView v = views.get(i);
        group.removeView(i);

        assertGroupNotContainsChild(group, v);

        Assert.assertNull("Removed view still has a parent", v.getSuperview());
    }
    Assert.assertEquals("ViewGroup still has subviews", 0, group.getSubviews().size());
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:21,代码来源:ViewGroupTest.java

示例9: testRemoveChildAtFront

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Test
public void testRemoveChildAtFront() throws Exception {
    NSMutableArray<UIView> views = new NSMutableArray<>(24);

    for (int i = 0; i < 24; i++) {
        UIView view = createViewWithText(String.valueOf(i + 1));
        views.add(view);
        group.addView(view);
    }

    UIView v = views.get(0);
    group.removeView(0);

    assertGroupNotContainsChild(group, v);
    Assert.assertNull("View still has a superview", v.getSuperview());

    Assert.assertEquals("ViewGroup has the wrong number of subviews", views.size() - 1, group.getSubviews().size());
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:19,代码来源:ViewGroupTest.java

示例10: testRemoveChildInMiddle

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Test
public void testRemoveChildInMiddle() throws Exception {
    NSMutableArray<UIView> views = new NSMutableArray<>(24);

    for (int i = 0; i < 24; i++) {
        UIView view = createViewWithText(String.valueOf(i + 1));
        views.add(view);
        group.addView(view);
    }

    UIView v = views.get(12);
    group.removeView(12);

    assertGroupNotContainsChild(group, v);
    Assert.assertNull("View still has a superview", v.getSuperview());

    Assert.assertEquals("ViewGroup has the wrong number of subviews", views.size() - 1, group.getSubviews().size());
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:19,代码来源:ViewGroupTest.java

示例11: getRelatedViewForRules

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public UIView getRelatedViewForRules(String[] rules, RelativeLayoutRule relation) {
    String identifier = rules[relation.getValue()];
    if(identifier != null) {
        DependencyGraphNode node = this.graph.getKeyNodes().get(identifier);
        if(node == null)
            return null;

        UIView v = node.getView();

        // Find the first non-GONE view up the chain
        while(UIViewLayoutUtil.getVisibility(v) == ViewVisibility.Gone) {
            rules = ((RelativeLayoutLayoutParams)UIViewLayoutUtil.getLayoutParams(v)).getRules();
            node = this.graph.getKeyNodes().get(rules[relation.getValue()]);

            if(node == null)
                return null;

            v = node.getView();
        }
        return v;
    }
    return null;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:24,代码来源:RelativeLayout.java

示例12: measureChildHorizontal

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public void measureChildHorizontal(UIView child, RelativeLayoutLayoutParams params, double myWidth, double myHeight) {
    UIEdgeInsets paramsMargin = params.getMargin();
    UIEdgeInsets padding = UIViewLayoutUtil.getPadding(this);

    LayoutMeasureSpec childWidthMeasureSpec = getChildMeasureSpec(params.getLeft(), params.getRight(), params.getWidth(),
            paramsMargin.getLeft(), paramsMargin.getRight(), padding.getLeft(),
            padding.getRight(), myWidth);

    LayoutMeasureSpec childHeightMeasureSpec;
    if(params.getWidth() == LayoutParamsSize.MatchParent.getValue()) {
        childHeightMeasureSpec = new LayoutMeasureSpec(myHeight - padding.getTop()- padding.getBottom(), LayoutMeasureSpecMode.Exactly);
    } else {
        childHeightMeasureSpec = new LayoutMeasureSpec(myHeight - padding.getTop()- padding.getBottom(), LayoutMeasureSpecMode.AtMost);
    }
    UIViewLayoutUtil.measure(child, childWidthMeasureSpec, childHeightMeasureSpec);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:17,代码来源:RelativeLayout.java

示例13: didPressButton

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Method(selector = "didPressButton")
public void didPressButton() {
    UILabel textLabel = (UILabel) UIViewLayoutUtil.findViewById(getView(), "text");
    if(textLabel.getText().equals("Short text")) {
        textLabel.setText("Very long long text");
    } else {
        textLabel.setText("Short text");
    }

    UIView.animate(0.2, new Runnable() {
        @Override
        public void run() {
            getView().layoutIfNeeded();
        }
    });
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:17,代码来源:LayoutAnimationsViewController.java

示例14: MyViewController

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public MyViewController() {
    // Get the view of this view controller.
    UIView view = getView();

    // Setup background.
    view.setBackgroundColor(UIColor.white());

    // Setup label.
    label = new UILabel(new CGRect(20, 250, 280, 44));
    label.setFont(UIFont.getSystemFont(24));
    label.setTextAlignment(NSTextAlignment.Center);
    view.addSubview(label);

    // Setup button.
    button = new UIButton(UIButtonType.RoundedRect);
    button.setFrame(new CGRect(110, 150, 100, 40));
    button.setTitle("Click me!", UIControlState.Normal);
    button.getTitleLabel().setFont(UIFont.getBoldSystemFont(22));

    button.addOnTouchUpInsideListener((control, event) -> label.setText("Click Nr. " + (++clickCount)));
    view.addSubview(button);
}
 
开发者ID:robovm,项目名称:robovm-templates,代码行数:23,代码来源:MyViewController.java

示例15: PAPLoadMoreCell

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
public PAPLoadMoreCell(UITableViewCellStyle style, String reuseIdentifier) {
    super(style, reuseIdentifier);

    setOpaque(false);
    setSelectionStyle(UITableViewCellSelectionStyle.None);
    setAccessoryType(UITableViewCellAccessoryType.None);
    setBackgroundColor(UIColor.clear());

    mainView = new UIView(getContentView().getFrame());
    if (reuseIdentifier.equals("NextPageDetails")) {
        mainView.setBackgroundColor(UIColor.white());
    } else {
        mainView.setBackgroundColor(UIColor.black());
    }

    loadMoreImageView = new UIImageView(UIImage.getImage("CellLoadMore"));
    mainView.addSubview(loadMoreImageView);

    getContentView().addSubview(mainView);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:PAPLoadMoreCell.java


注:本文中的org.robovm.apple.uikit.UIView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。