com.qmuiteam.qmui.util.QMUIDisplayHelper Java Examples

The following examples show how to use com.qmuiteam.qmui.util.QMUIDisplayHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QMUISpanActivity.java    From BaseUIFrame with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ButterKnife.bind(mActivity);
    title = getIntent().getStringExtra(MyApp.INTENT_VALUE_TITLE_STR);
    if (title != null) {
        topBar.setTitle(title);
    }


    int alignMiddleIconLength = QMUIDisplayHelper.dp2px(mActivity, 20);
    final float spanWidthCharacterCount = 2f;
    SpannableString spannable = new SpannableString("[icon]" + "这是一行示例文字,前面的 Span 设置了和文字垂直居中并占 " + spanWidthCharacterCount + " 个中文字的宽度");
    Drawable iconDrawable = QMUIDrawableHelper.createDrawableWithSize(getResources(), alignMiddleIconLength, alignMiddleIconLength, QMUIDisplayHelper.dp2px(mActivity, 4), ContextCompat.getColor(mActivity, R.color.app_color_theme_3));
    if (iconDrawable != null) {
        iconDrawable.setBounds(0, 0, iconDrawable.getIntrinsicWidth(), iconDrawable.getIntrinsicHeight());
    }
    ImageSpan alignMiddleImageSpan = new QMUIAlignMiddleImageSpan(iconDrawable, QMUIAlignMiddleImageSpan.ALIGN_MIDDLE, spanWidthCharacterCount);
    spannable.setSpan(alignMiddleImageSpan, 0, "[icon]".length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    mAlignMiddleTextView.setText(spannable);
}
 
Example #2
Source File: MainActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void handlerContentMargin() {
    if (contentFrameLayout == null || bottomNavigationBar == null || !presenter.isFixMainNavigation()) {
        return;
    }
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) contentFrameLayout.getLayoutParams();
    layoutParams.bottomMargin = QMUIDisplayHelper.getActionBarHeight(this);
    contentFrameLayout.setLayoutParams(layoutParams);
}
 
Example #3
Source File: MineFragment.java    From v9porn with MIT License 5 votes vote down vote up
private void handlerMargin() {
    if (presenter.isFixMainNavigation()) {
        return;
    }
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) rootRelativeLayout.getLayoutParams();
    layoutParams.bottomMargin = QMUIDisplayHelper.getActionBarHeight(context);
    rootRelativeLayout.setLayoutParams(layoutParams);
}
 
Example #4
Source File: MainActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void handlerContentMargin() {
    if (contentFrameLayout == null || bottomNavigationBar == null || !presenter.isFixMainNavigation()) {
        return;
    }
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) contentFrameLayout.getLayoutParams();
    layoutParams.bottomMargin = QMUIDisplayHelper.getActionBarHeight(this);
    contentFrameLayout.setLayoutParams(layoutParams);
}
 
Example #5
Source File: MineFragment.java    From v9porn with MIT License 5 votes vote down vote up
private void handlerMargin() {
    if (presenter.isFixMainNavigation()) {
        return;
    }
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) rootRelativeLayout.getLayoutParams();
    layoutParams.bottomMargin = QMUIDisplayHelper.getActionBarHeight(context);
    rootRelativeLayout.setLayoutParams(layoutParams);
}
 
Example #6
Source File: PersonActivity.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);
    layout.setPadding(padding, padding, padding, padding);
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("在此输入您的个性签名,字数限制在50个以内");
    mEditText.setText(signature
    );
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(100));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);
    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
    textView.setText("推荐输入诗词作为个性签名。\n" +
            "例如:\n" +
            "众里寻他千百度,蓦然回首,那人却在灯火阑珊处。");
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.gray));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);
    return layout;
}
 
Example #7
Source File: QMUIPopupActivity.java    From BaseUIFrame with MIT License 5 votes vote down vote up
private void initListPopupIfNeed() {
    if (mListPopup == null) {

        String[] listItems = new String[]{
                "Item 1",
                "Item 2",
                "Item 3",
                "Item 4",
                "Item 5",
        };
        List<String> data = new ArrayList<>();

        Collections.addAll(data, listItems);

        ArrayAdapter adapter = new ArrayAdapter<>(mActivity, android.R.layout.simple_list_item_1, data);

        mListPopup = new QMUIListPopup(mActivity, QMUIPopup.DIRECTION_NONE, adapter);
        mListPopup.create(QMUIDisplayHelper.dp2px(mActivity, 250), QMUIDisplayHelper.dp2px(mActivity, 200), new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ToastUtil.showToast("Item " + (i + 1));
                mListPopup.dismiss();
            }
        });
        mListPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mActionButton2.setText("显示列表浮层");
            }
        });
    }
}
 
Example #8
Source File: QMUIFloatLayoutActivity.java    From BaseUIFrame with MIT License 5 votes vote down vote up
private void addItemToFloatLayout(QMUIFloatLayout floatLayout){
    int currentChildCount = floatLayout.getChildCount();

    TextView textView = new TextView(mActivity);
    int textViewPadding = QMUIDisplayHelper.dp2px(mActivity, 4);
    textView.setPadding(textViewPadding, textViewPadding, textViewPadding, textViewPadding);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
    textView.setTextColor(ContextCompat.getColor(mActivity, R.color.qmui_config_color_white));
    textView.setText(String.valueOf(currentChildCount));
    textView.setBackgroundResource(currentChildCount % 2 == 0 ? R.color.app_color_theme_3 : R.color.app_color_theme_6);

    int textViewSize = QMUIDisplayHelper.dpToPx(60);
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(textViewSize, textViewSize);
    floatLayout.addView(textView, lp);
}
 
Example #9
Source File: QMUIDialogActivity.java    From BaseUIFrame with MIT License 5 votes vote down vote up
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    //初始化布局
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    //设置布局参数
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);//内边距20dp
    layout.setPadding(padding, padding, padding, padding);
    //初始化组件
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("输入框");
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(mActivity, 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);

    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(mActivity, 4), 1.0f);
    textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
            "QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
            "同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
            "不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
    textView.setTextColor(ContextCompat.getColor(mActivity, R.color.app_color_description));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);

    return layout;
}
 
Example #10
Source File: PlayPxgavActivity.java    From v9porn with MIT License 4 votes vote down vote up
/**
 * 根据屏幕宽度信息重设videoview宽高为16:9比例
 */
protected void setVideoViewHeight(View playerView) {
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) playerView.getLayoutParams();
    layoutParams.height = QMUIDisplayHelper.getScreenWidth(this) * 9 / 16;
    playerView.setLayoutParams(layoutParams);
}
 
Example #11
Source File: MeiZiTuFragment.java    From v9porn with MIT License 4 votes vote down vote up
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    meiZiTuAdapter.setWidth(QMUIDisplayHelper.getScreenWidth(context) / 2);
}
 
Example #12
Source File: PlayPxgavActivity.java    From v9porn with MIT License 4 votes vote down vote up
/**
 * 根据屏幕宽度信息重设videoview宽高为16:9比例
 */
protected void setVideoViewHeight(View playerView) {
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) playerView.getLayoutParams();
    layoutParams.height = QMUIDisplayHelper.getScreenWidth(this) * 9 / 16;
    playerView.setLayoutParams(layoutParams);
}
 
Example #13
Source File: MeiZiTuFragment.java    From v9porn with MIT License 4 votes vote down vote up
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    meiZiTuAdapter.setWidth(QMUIDisplayHelper.getScreenWidth(context) / 2);
}
 
Example #14
Source File: FireflyBottomSheet.java    From smart-farmer-android with Apache License 2.0 4 votes vote down vote up
protected int getListMaxHeight() {
    return (int) (QMUIDisplayHelper.getScreenHeight(mContext) * 0.4);
}
 
Example #15
Source File: FireflyBottomSheet.java    From smart-farmer-android with Apache License 2.0 4 votes vote down vote up
private int getListMaxHeight() {
    return (int) (QMUIDisplayHelper.getScreenHeight(mContext) * 0.4);
}
 
Example #16
Source File: FireflyBottomSheet.java    From smart-farmer-android with Apache License 2.0 4 votes vote down vote up
private int getListMaxHeight() {
    return (int) (QMUIDisplayHelper.getScreenHeight(mContext) * 0.4);
}