• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UIView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: viewDidLoad

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Override
public void viewDidLoad() {
    super.viewDidLoad();

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("LogoNavigationBar")));

    getNavigationItem().setRightBarButtonItem(new PAPSettingsButtonItem(settingsButtonAction));

    blankTimelineView = new UIView(getTableView().getBounds());

    UIButton button = new UIButton(UIButtonType.Custom);
    button.setFrame(new CGRect(33, 96, 253, 173));
    button.setBackgroundImage(UIImage.getImage("HomeTimelineBlank"), UIControlState.Normal);
    button.addOnTouchUpInsideListener(inviteFriendsButtonAction);
    blankTimelineView.addSubview(button);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:17,代码来源:PAPHomeViewController.java


示例17: didLoadObjects

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
@Override
public void didLoadObjects(NSError error) {
    super.didLoadObjects(error);

    if (getObjects().size() == 0 && !getQuery().hasCachedResult() && !firstLaunch) {
        getTableView().setScrollEnabled(false);

        if (blankTimelineView.getSuperview() == null) {
            blankTimelineView.setAlpha(0);
            getTableView().setTableHeaderView(blankTimelineView);

            UIView.animate(0.2, new Runnable() {
                @Override
                public void run() {
                    blankTimelineView.setAlpha(1);
                }
            });
        }
    } else {
        getTableView().setTableHeaderView(null);
        getTableView().setScrollEnabled(true);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:PAPHomeViewController.java


示例18: updateView

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
private void updateView(final CLLocation location) {
    // We animate transition from one position to the next, this makes the
    // dot move smoothly over the map
    UIView.animate(0.75, new Runnable() {
        @Override
        public void run() {
            // Call the converter to find these coordinates on our
            // floorplan.
            CGPoint pointOnImage = coordinateConverter.getPointFromCoordinate(location.getCoordinate());

            // These coordinates need to be scaled based on how much the
            // image has been scaled
            CGPoint scaledPoint = new CGPoint(pointOnImage.getX() * displayScale + displayOffset.getX(),
                    pointOnImage.getY()
                            * displayScale + displayOffset.getY());

            // Calculate and set the size of the radius
            double radiusFrameSize = location.getHorizontalAccuracy() * coordinateConverter.getPixelsPerMeter() * 2;
            radiusView.setFrame(new CGRect(0, 0, radiusFrameSize, radiusFrameSize));

            // Move the pin and radius to the user's location
            pinView.setCenter(scaledPoint);
            radiusView.setCenter(scaledPoint);
        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:27,代码来源:AAPLViewController.java


示例19: dispatchTouchEndEvent

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
/**
 * Checks to see which view, or views, the point is in and then calls a
 * method to perform the closing animation, which is to return the piece to
 * its original size, as if it is being put down by the user.
 */
private void dispatchTouchEndEvent(UIView view, CGPoint position) {
    // Check to see which view, or views, the point is in and then animate
    // to that position.
    if (firstPieceView.getFrame().contains(position)) {
        animateView(firstPieceView, position);
    }
    if (secondPieceView.getFrame().contains(position)) {
        animateView(secondPieceView, position);
    }
    if (thirdPieceView.getFrame().contains(position)) {
        animateView(thirdPieceView, position);
    }

    // If one piece obscures another, display a message so the user can move
    // the pieces apart.
    if (firstPieceView.getCenter().equalsTo(secondPieceView.getCenter()) ||
            firstPieceView.getCenter().equalsTo(thirdPieceView.getCenter()) ||
            secondPieceView.getCenter().equalsTo(thirdPieceView.getCenter())) {
        touchInstructionsText.setText("Double tap the background to move the pieces apart.");
        piecesOnTop = true;
    } else {
        piecesOnTop = false;
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:30,代码来源:APLViewController.java


示例20: panPiece

import org.robovm.apple.uikit.UIView; //导入依赖的package包/类
/**
 * Shift the piece's center by the pan amount. Reset the gesture
 * recognizer's translation to {0, 0} after applying so the next callback is
 * a delta from the current position.
 */
@IBAction
private void panPiece(UIPanGestureRecognizer gestureRecognizer) {
    UIView piece = gestureRecognizer.getView();

    adjustAnchorPointForGestureRecognizer(gestureRecognizer);

    if (gestureRecognizer.getState() == UIGestureRecognizerState.Began
            || gestureRecognizer.getState() == UIGestureRecognizerState.Changed) {
        CGPoint translation = gestureRecognizer.getTranslation(piece.getSuperview());

        piece.setCenter(new CGPoint(piece.getCenter().getX() + translation.getX(), piece.getCenter().getY()
                + translation.getY()));
        gestureRecognizer.setTranslation(CGPoint.Zero(), piece.getSuperview());
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:APLViewController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DeterministicHierarchy类代码示例发布时间:2022-05-23
下一篇:
Java Utf8String类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap