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


Java PopupWindow.getContentView方法代码示例

本文整理汇总了Java中android.widget.PopupWindow.getContentView方法的典型用法代码示例。如果您正苦于以下问题:Java PopupWindow.getContentView方法的具体用法?Java PopupWindow.getContentView怎么用?Java PopupWindow.getContentView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.PopupWindow的用法示例。


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

示例1: testPopupWindowChangeColor

import android.widget.PopupWindow; //导入方法依赖的package包/类
@Test
public void testPopupWindowChangeColor() {
    mFieldColorView.performClick();
    final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow();
    final View popupWindowContentView = popupWindow.getContentView();
    assertThat(popupWindowContentView).isNotNull();

    // Reset color before test.
    mFieldColor.setColor(0);
    assertThat(mFieldColor.getColor()).isEqualTo(0);

    // Simulate click on the color panel.
    popupWindowContentView.onTouchEvent(
            MotionEvent.obtain(0 /* downTime */, 0 /* eventTime */, MotionEvent.ACTION_DOWN,
                    0f /* x */, 0f /* y */, 0 /* metaState */));

    // Verify both field and field view background have been set to correct color.
    final int expectedColour = 0xffffff;
    assertThat(mFieldColor.getColor())
            .isEqualTo(expectedColour);  // setColour() masks out alpha.
    assertThat(((ColorDrawable) mFieldColorView.getBackground()).getColor())
            .isEqualTo(BasicFieldColorView.ALPHA_OPAQUE | expectedColour);

    // Popup window should have disappeared.
    assertThat(popupWindow.isShowing()).isFalse();
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:27,代码来源:BasicFieldColorViewTest.java

示例2: revealPopupWindow

import android.widget.PopupWindow; //导入方法依赖的package包/类
@UiThread public static void revealPopupWindow(@NonNull PopupWindow popupWindow, @NonNull View from) {
    Rect rect = ViewHelper.getLayoutPosition(from);
    int x = (int) rect.exactCenterX();
    int y = (int) rect.exactCenterY();
    if (popupWindow.getContentView() != null) {
        View view = popupWindow.getContentView();
        if (view != null) {
            popupWindow.showAsDropDown(from);
            view.post(() -> {
                if (ViewCompat.isAttachedToWindow(view)) {
                    Animator animator = ViewAnimationUtils.createCircularReveal(view, x, y, 0,
                            (float) Math.hypot(rect.width(), rect.height()));
                    animator.setDuration(view.getResources().getInteger(android.R.integer.config_shortAnimTime));
                    animator.start();
                }
            });
        }
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:20,代码来源:AnimHelper.java

示例3: getOffset

import android.widget.PopupWindow; //导入方法依赖的package包/类
public int[] getOffset(View anchor, PopupWindow window) {
    int anchWidth=anchor.getWidth();
    int anchHeight=anchor.getHeight();

    int winWidth=window.getWidth();
    int winHeight=window.getHeight();
    View view=window.getContentView();
    if(winWidth<=0)
        winWidth=view.getWidth();
    if(winHeight<=0)
        winHeight=view.getHeight();

    int xoff=0;
    int yoff=0;

    switch (getHoriParam()) {
        case ALIGN_LEFT:
            xoff=0; break;
        case ALIGN_RIGHT:
            xoff=anchWidth-winWidth; break;
        case TO_LEFT:
            xoff=-winWidth; break;
        case TO_RIGHT:
            xoff=anchWidth; break;
        case CENTER_HORI:
            xoff=(anchWidth-winWidth)/2; break;
        default:break;
    }
    switch (getVertParam()) {
        case ALIGN_ABOVE:
            yoff=-anchHeight; break;
        case ALIGN_BOTTOM:
            yoff=-winHeight; break;
        case TO_ABOVE:
            yoff=-anchHeight-winHeight; break;
        case TO_BOTTOM:
            yoff=0; break;
        case CENTER_VERT:
            yoff=(-winHeight-anchHeight)/2; break;
        default:break;
    }
    return new int[]{ xoff, yoff };
}
 
开发者ID:jzyhywxz,项目名称:PopupWindow,代码行数:44,代码来源:CommonPopupWindow.java


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