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


Java Util.dpToPx方法代码示例

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


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

示例1: refreshLeftIcon

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
private void refreshLeftIcon() {
    int leftActionWidthAndMarginLeft = Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START);
    int queryTranslationX = 0;

    mLeftAction.setVisibility(VISIBLE);
    switch (mLeftActionMode) {
        case LEFT_ACTION_MODE_SHOW_HAMBURGER:
            mLeftAction.setImageDrawable(mMenuBtnDrawable);
            break;
        case LEFT_ACTION_MODE_SHOW_SEARCH:
            mLeftAction.setImageDrawable(mIconSearch);
            break;
        case LEFT_ACTION_MODE_SHOW_HOME:
            mLeftAction.setImageDrawable(mMenuBtnDrawable);
            mMenuBtnDrawable.setProgress(1.0f);
            break;
        case LEFT_ACTION_MODE_NO_LEFT_ACTION:
            mLeftAction.setVisibility(View.INVISIBLE);
            queryTranslationX = -leftActionWidthAndMarginLeft;
            break;
    }
    mSearchInputParent.setTranslationX(queryTranslationX);
}
 
开发者ID:JasonChow1989,项目名称:Floatingsearchview-master,代码行数:24,代码来源:FloatingSearchView.java

示例2: refreshLeftIcon

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
private void refreshLeftIcon() {
    int leftActionWidthAndMarginLeft = Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START_DP);
    int queryTranslationX = 0;

    mLeftAction.setVisibility(VISIBLE);
    switch (mLeftActionMode) {
        case LEFT_ACTION_MODE_SHOW_HAMBURGER:
            mLeftAction.setImageDrawable(mMenuBtnDrawable);
            mMenuBtnDrawable.setProgress(MENU_BUTTON_PROGRESS_HAMBURGER);
            break;
        case LEFT_ACTION_MODE_SHOW_SEARCH:
            mLeftAction.setImageDrawable(mIconSearch);
            break;
        case LEFT_ACTION_MODE_SHOW_HOME:
            mLeftAction.setImageDrawable(mMenuBtnDrawable);
            mMenuBtnDrawable.setProgress(MENU_BUTTON_PROGRESS_ARROW);
            break;
        case LEFT_ACTION_MODE_NO_LEFT_ACTION:
            mLeftAction.setVisibility(View.INVISIBLE);
            queryTranslationX = -leftActionWidthAndMarginLeft;
            break;
    }
    mSearchInputParent.setTranslationX(queryTranslationX);
}
 
开发者ID:arimorty,项目名称:floatingsearchview,代码行数:25,代码来源:FloatingSearchView.java

示例3: onLayout

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    if (mIsInitialLayout) {

        //we need to add 5dp to the mSuggestionsSection because we are
        //going to move it up by 5dp in order to cover the search bar's
        //shadow padding and rounded corners. We also need to add an additional 10dp to
        //mSuggestionsSection in order to hide mSuggestionListContainer's
        //rounded corners and shadow for both, top and bottom.
        int addedHeight = 3 * Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
        final int finalHeight = mSuggestionsSection.getHeight() + addedHeight;
        mSuggestionsSection.getLayoutParams().height = finalHeight;
        mSuggestionsSection.requestLayout();
        ViewTreeObserver vto = mSuggestionListContainer.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {

                if (mSuggestionsSection.getHeight() == finalHeight) {
                    Util.removeGlobalLayoutObserver(mSuggestionListContainer, this);

                    mIsSuggestionsSecHeightSet = true;
                    moveSuggestListToInitialPos();
                    if (mSuggestionSecHeightListener != null) {
                        mSuggestionSecHeightListener.onSuggestionSecHeightSet();
                        mSuggestionSecHeightListener = null;
                    }
                }
            }
        });

        mIsInitialLayout = false;

        refreshDimBackground();
    }
}
 
开发者ID:JasonChow1989,项目名称:Floatingsearchview-master,代码行数:39,代码来源:FloatingSearchView.java

示例4: FloatingSearchView

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
public FloatingSearchView(Context context, AttributeSet attrs) {
    super(context, attrs);
    SEARCH_BAR_LEFT_SECTION_DESIRED_WIDTH = Util.dpToPx(225);
    init(attrs);
}
 
开发者ID:JasonChow1989,项目名称:Floatingsearchview-master,代码行数:6,代码来源:FloatingSearchView.java

示例5: applyXmlAttributes

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
private void applyXmlAttributes(AttributeSet attrs) {

        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView);

        try {

            int searchBarWidth = a.getDimensionPixelSize(
                    R.styleable.FloatingSearchView_floatingSearch_searchBarWidth,
                    ViewGroup.LayoutParams.MATCH_PARENT);
            mQuerySection.getLayoutParams().width = searchBarWidth;
            mDivider.getLayoutParams().width = searchBarWidth;
            mSuggestionListContainer.getLayoutParams().width = searchBarWidth;
            int searchBarLeftMargin = a.getDimensionPixelSize(
                    R.styleable.FloatingSearchView_floatingSearch_searchBarMarginLeft,
                    ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
            int searchBarTopMargin = a.getDimensionPixelSize(
                    R.styleable.FloatingSearchView_floatingSearch_searchBarMarginTop,
                    ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
            int searchBarRightMargin = a.getDimensionPixelSize(
                    R.styleable.FloatingSearchView_floatingSearch_searchBarMarginRight,
                    ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
            LayoutParams querySectionLP = (LayoutParams) mQuerySection.getLayoutParams();
            LayoutParams dividerLP = (LayoutParams) mDivider.getLayoutParams();
            LinearLayout.LayoutParams suggestListSectionLP =
                    (LinearLayout.LayoutParams) mSuggestionsSection.getLayoutParams();
            int cardPadding = Util.dpToPx(CARD_VIEW_TOP_BOTTOM_SHADOW_HEIGHT);
            querySectionLP.setMargins(searchBarLeftMargin, searchBarTopMargin,
                    searchBarRightMargin, 0);
            dividerLP.setMargins(searchBarLeftMargin + cardPadding, 0,
                    searchBarRightMargin + cardPadding,
                    ((MarginLayoutParams) mDivider.getLayoutParams()).bottomMargin);
            suggestListSectionLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin, 0);
            mQuerySection.setLayoutParams(querySectionLP);
            mDivider.setLayoutParams(dividerLP);
            mSuggestionsSection.setLayoutParams(suggestListSectionLP);

            setSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_searchHint));
            setShowSearchKey(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchKey,
                    ATTRS_SEARCH_BAR_SHOW_SEARCH_KEY_DEFAULT));
            setDismissOnOutsideClick(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dismissOnOutsideTouch,
                    ATTRS_DISMISS_ON_OUTSIDE_TOUCH_DEFAULT));
            setSuggestionItemTextSize(a.getDimensionPixelSize(
                    R.styleable.FloatingSearchView_floatingSearch_searchSuggestionTextSize,
                    Util.spToPx(ATTRS_SUGGESTION_TEXT_SIZE_SP_DEFAULT)));
            //noinspection ResourceType
            mLeftActionMode = a.getInt(R.styleable.FloatingSearchView_floatingSearch_leftActionMode,
                    ATTRS_SEARCH_BAR_LEFT_ACTION_MODE_DEFAULT);
            if (a.hasValue(R.styleable.FloatingSearchView_floatingSearch_menu)) {
                mMenuId = a.getResourceId(R.styleable.FloatingSearchView_floatingSearch_menu, -1);
            }
            setDimBackground(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dimBackground,
                    ATTRS_SHOW_DIM_BACKGROUND_DEFAULT));
            setShowMoveUpSuggestion(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showMoveSuggestionUp,
                    ATTRS_SHOW_MOVE_UP_SUGGESTION_DEFAULT));
            this.mSuggestionSectionAnimDuration = a.getInt(R.styleable.FloatingSearchView_floatingSearch_suggestionsListAnimDuration,
                    ATTRS_SUGGESTION_ANIM_DURATION_DEFAULT);
            setBackgroundColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_backgroundColor
                    , Util.getColor(getContext(), R.color.background)));
            setLeftActionIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_leftActionColor
                    , Util.getColor(getContext(), R.color.left_action_icon)));
            setActionMenuOverflowColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_actionMenuOverflowColor
                    , Util.getColor(getContext(), R.color.overflow_icon_color)));
            setMenuItemIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_menuItemIconColor
                    , Util.getColor(getContext(), R.color.menu_icon_color)));
            setDividerColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_dividerColor
                    , Util.getColor(getContext(), R.color.divider)));
            setClearBtnColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_clearBtnColor
                    , Util.getColor(getContext(), R.color.clear_btn_color)));
            setViewTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_viewTextColor
                    , Util.getColor(getContext(), R.color.dark_gray)));
            setHintTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_hintTextColor
                    , Util.getColor(getContext(), R.color.hint_color)));
            setSuggestionRightIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_suggestionRightIconColor
                    , Util.getColor(getContext(), R.color.gray_active_icon)));
        } finally {
            a.recycle();
        }
    }
 
开发者ID:JasonChow1989,项目名称:Floatingsearchview-master,代码行数:79,代码来源:FloatingSearchView.java

示例6: actionMenuAvailWidth

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
private int actionMenuAvailWidth() {
    if (isInEditMode()) {
        return Util.dpToPx(360) - SEARCH_BAR_LEFT_SECTION_DESIRED_WIDTH;
    }
    return mQuerySection.getWidth() - SEARCH_BAR_LEFT_SECTION_DESIRED_WIDTH;
}
 
开发者ID:JasonChow1989,项目名称:Floatingsearchview-master,代码行数:7,代码来源:FloatingSearchView.java

示例7: onLayout

import com.arlib.floatingsearchview.util.Util; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    if (mIsInitialLayout) {

        //we need to add 5dp to the mSuggestionsSection because we are
        //going to move it up by 5dp in order to cover the search bar's
        //shadow padding and rounded corners. We also need to add an additional 10dp to
        //mSuggestionsSection in order to hide mSuggestionListContainer's
        //rounded corners and shadow for both, top and bottom.
        int addedHeight = 3 * Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
        final int finalHeight = mSuggestionsSection.getHeight() + addedHeight;
        mSuggestionsSection.getLayoutParams().height = finalHeight;
        mSuggestionsSection.requestLayout();
        ViewTreeObserver vto = mSuggestionListContainer.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {

                if (mSuggestionsSection.getHeight() == finalHeight) {
                    Util.removeGlobalLayoutObserver(mSuggestionListContainer, this);

                    mIsSuggestionsSectionHeightSet = true;
                    moveSuggestListToInitialPos();
                    if (mSuggestionSecHeightListener != null) {
                        mSuggestionSecHeightListener.onSuggestionSecHeightSet();
                        mSuggestionSecHeightListener = null;
                    }
                }
            }
        });

        mIsInitialLayout = false;

        refreshDimBackground();

        if (isInEditMode()) {
            inflateOverflowMenu(mMenuId);
        }
    }
}
 
开发者ID:arimorty,项目名称:floatingsearchview,代码行数:43,代码来源:FloatingSearchView.java


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