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


Java WXViewUtils.dip2px方法代码示例

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


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

示例1: makeTitleView

import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
private TextView makeTitleView(Context context, Map<String, Object> options) {
    String text = getOption(options, KEY_TITLE, null);
    if (text == null) {
        return null;
    }
    TextView textView = new TextView(context);
    textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    int padding = WXViewUtils.dip2px(12);
    textView.setPadding(padding, padding, padding, padding);
    textView.getPaint().setFakeBoldText(true);
    textView.setBackgroundColor(getColor(options, KEY_TITLE_BACKGROUND_COLOR, Color.TRANSPARENT));
    textView.setTextColor(getColor(options, KEY_TITLE_COLOR, Color.BLACK));
    textView.setText(text);
    return textView;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:17,代码来源:WXPickersModule.java

示例2: getAttrs

import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
/**
 * Get attribute of xml
 */
private void getAttrs(Context context) {
  radius = WXViewUtils.dip2px(5);
  circlePadding = WXViewUtils.dip2px(5);
  pageColor = Color.parseColor("#ffffff");
  //		strokeWidth= WAViewUtils.dip2px((float)1.5);
  //		strokeColor = Color.parseColor("#FFDDDDDD");
  fillColor = Color.parseColor("#ffd545");
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:12,代码来源:WXBaseCircleIndicator.java

示例3: isKeyboardVisible

import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
public static boolean isKeyboardVisible(Activity activity) {
    Rect windowFrame = new Rect();
    View root = getActivityRoot(activity);

    if (root != null) {
        root.getWindowVisibleDisplayFrame(windowFrame);
        int heightDiff = root.getRootView().getHeight() - windowFrame.height();
        return heightDiff > WXViewUtils.dip2px(KEYBOARD_VISIBLE_THRESHOLD_DIP);
    }
    return false;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:12,代码来源:SoftKeyboardDetector.java

示例4: registerKeyboardEventListener

import com.taobao.weex.utils.WXViewUtils; //导入方法依赖的package包/类
public static Unregister registerKeyboardEventListener(Activity activity, final OnKeyboardEventListener listener) {
    if (activity == null || listener == null) {
        WXLogUtils.e("Activity or listener is null!");
        return null;
    }

    if (activity.getWindow() != null) {
        WindowManager.LayoutParams attributes = activity.getWindow().getAttributes();
        if (attributes != null) {
            int softInputMode = attributes.softInputMode;
            if (softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING
                    || softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) {
                WXLogUtils.e("SoftKeyboard detector can't work with softInputMode is SOFT_INPUT_ADJUST_NOTHING or SOFT_INPUT_ADJUST_PAN");
                return null;
            }
        }
    }

    final View activityRoot = getActivityRoot(activity);

    if (activityRoot == null) {
        WXLogUtils.e("Activity root is null!");
        return null;
    }

    final ViewTreeObserver.OnGlobalLayoutListener layoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {

        private final Rect visibleFrame = new Rect();
        private final int threshold = WXViewUtils.dip2px(KEYBOARD_VISIBLE_THRESHOLD_DIP);
        private boolean wasKeyboardOpened = false;

        @Override
        public void onGlobalLayout() {
            activityRoot.getWindowVisibleDisplayFrame(visibleFrame);
            int heightDiff = activityRoot.getRootView().getHeight() - visibleFrame.height();
            boolean isOpen = heightDiff > threshold;
            if (isOpen == wasKeyboardOpened) {
                return;
            }

            wasKeyboardOpened = isOpen;
            listener.onKeyboardEvent(isOpen);
        }
    };

    activityRoot.getViewTreeObserver().addOnGlobalLayoutListener(layoutListener);
    return new DefaultUnRegister(activity, layoutListener);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:49,代码来源:SoftKeyboardDetector.java


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