Search in sources :

Example 6 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project Carbon by ZieIony.

the class Toolbar method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = 0;
    int height = 0;
    int childState = 0;
    final int[] collapsingMargins = mTempMargins;
    final int marginStartIndex;
    final int marginEndIndex;
    if (ViewUtils.isLayoutRtl(this)) {
        marginStartIndex = 1;
        marginEndIndex = 0;
    } else {
        marginStartIndex = 0;
        marginEndIndex = 1;
    }
    // System views measure first.
    int navWidth = 0;
    if (shouldLayout(mNavButtonView)) {
        measureChildConstrained(mNavButtonView, widthMeasureSpec, width, heightMeasureSpec, 0, mMaxButtonHeight);
        navWidth = mNavButtonView.getMeasuredWidth() + getHorizontalMargins(mNavButtonView);
        height = Math.max(height, mNavButtonView.getMeasuredHeight() + getVerticalMargins(mNavButtonView));
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mNavButtonView));
    }
    if (shouldLayout(mCollapseButtonView)) {
        measureChildConstrained(mCollapseButtonView, widthMeasureSpec, width, heightMeasureSpec, 0, mMaxButtonHeight);
        navWidth = mCollapseButtonView.getMeasuredWidth() + getHorizontalMargins(mCollapseButtonView);
        height = Math.max(height, mCollapseButtonView.getMeasuredHeight() + getVerticalMargins(mCollapseButtonView));
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mCollapseButtonView));
    }
    final int contentInsetStart = getContentInsetStart();
    width += Math.max(contentInsetStart, navWidth);
    collapsingMargins[marginStartIndex] = Math.max(0, contentInsetStart - navWidth);
    int menuWidth = 0;
    if (shouldLayout(mMenuView)) {
        measureChildConstrained(mMenuView, widthMeasureSpec, width, heightMeasureSpec, 0, mMaxButtonHeight);
        menuWidth = mMenuView.getMeasuredWidth() + getHorizontalMargins(mMenuView);
        height = Math.max(height, mMenuView.getMeasuredHeight() + getVerticalMargins(mMenuView));
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mMenuView));
    }
    final int contentInsetEnd = getContentInsetEnd();
    width += Math.max(contentInsetEnd, menuWidth);
    collapsingMargins[marginEndIndex] = Math.max(0, contentInsetEnd - menuWidth);
    if (shouldLayout(mExpandedActionView)) {
        width += measureChildCollapseMargins(mExpandedActionView, widthMeasureSpec, width, heightMeasureSpec, 0, collapsingMargins);
        height = Math.max(height, mExpandedActionView.getMeasuredHeight() + getVerticalMargins(mExpandedActionView));
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mExpandedActionView));
    }
    if (shouldLayout(mLogoView)) {
        width += measureChildCollapseMargins(mLogoView, widthMeasureSpec, width, heightMeasureSpec, 0, collapsingMargins);
        height = Math.max(height, mLogoView.getMeasuredHeight() + getVerticalMargins(mLogoView));
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mLogoView));
    }
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (lp.mViewType != LayoutParams.CUSTOM || !shouldLayout(child)) {
            // We already got all system views above. Skip them and GONE views.
            continue;
        }
        width += measureChildCollapseMargins(child, widthMeasureSpec, width, heightMeasureSpec, 0, collapsingMargins);
        height = Math.max(height, child.getMeasuredHeight() + getVerticalMargins(child));
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child));
    }
    int titleWidth = 0;
    int titleHeight = 0;
    final int titleVertMargins = mTitleMarginTop + mTitleMarginBottom;
    final int titleHorizMargins = mTitleMarginStart + mTitleMarginEnd;
    if (shouldLayout(mTitleTextView)) {
        titleWidth = measureChildCollapseMargins(mTitleTextView, widthMeasureSpec, width + titleHorizMargins, heightMeasureSpec, titleVertMargins, collapsingMargins);
        titleWidth = mTitleTextView.getMeasuredWidth() + getHorizontalMargins(mTitleTextView);
        titleHeight = mTitleTextView.getMeasuredHeight() + getVerticalMargins(mTitleTextView);
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mTitleTextView));
    }
    if (shouldLayout(mSubtitleTextView)) {
        titleWidth = Math.max(titleWidth, measureChildCollapseMargins(mSubtitleTextView, widthMeasureSpec, width + titleHorizMargins, heightMeasureSpec, titleHeight + titleVertMargins, collapsingMargins));
        titleHeight += mSubtitleTextView.getMeasuredHeight() + getVerticalMargins(mSubtitleTextView);
        childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(mSubtitleTextView));
    }
    width += titleWidth;
    height = Math.max(height, titleHeight);
    // Measurement already took padding into account for available space for the children,
    // add it in for the final size.
    width += getPaddingLeft() + getPaddingRight();
    height += getPaddingTop() + getPaddingBottom();
    final int measuredWidth = ViewCompat.resolveSizeAndState(Math.max(width, getSuggestedMinimumWidth()), widthMeasureSpec, childState & ViewCompat.MEASURED_STATE_MASK);
    final int measuredHeight = ViewCompat.resolveSizeAndState(Math.max(height, getSuggestedMinimumHeight()), heightMeasureSpec, childState << ViewCompat.MEASURED_HEIGHT_STATE_SHIFT);
    setMeasuredDimension(measuredWidth, shouldCollapse() ? 0 : measuredHeight);
}
Also used : CollapsibleActionView(android.support.v7.view.CollapsibleActionView) MenuView(android.support.v7.view.menu.MenuView) View(android.view.View) ImageView(carbon.widget.ImageView) TextView(carbon.widget.TextView) ActionMenuView(android.support.v7.widget.ActionMenuView)

Example 7 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project Carbon by ZieIony.

the class Toolbar method setChildVisibilityForExpandedActionView.

/**
     * @ hide
     */
/*public DecorToolbar getWrapper() {
        if (mWrapper == null) {
            mWrapper = new ToolbarWidgetWrapper(this, true);
        }
        return mWrapper;
    }*/
private void setChildVisibilityForExpandedActionView(boolean expand) {
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (lp.mViewType != LayoutParams.EXPANDED && child != mMenuView) {
            child.setVisibility(expand ? GONE : VISIBLE);
        }
    }
}
Also used : CollapsibleActionView(android.support.v7.view.CollapsibleActionView) MenuView(android.support.v7.view.menu.MenuView) View(android.view.View) ImageView(carbon.widget.ImageView) TextView(carbon.widget.TextView) ActionMenuView(android.support.v7.widget.ActionMenuView)

Example 8 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project actor-platform by actorapp.

the class BaseContactFragment method addFooterOrHeaderAction.

protected void addFooterOrHeaderAction(int color, int icon, int text, boolean isLast, final Runnable action, boolean isHeader) {
    FrameLayout container = new FrameLayout(getActivity());
    container.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    {
        container.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }
    FrameLayout invitePanel = new FrameLayout(getActivity());
    invitePanel.setBackgroundResource(R.drawable.selector_fill);
    invitePanel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            action.run();
        }
    });
    {
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(64));
        params.leftMargin = Screen.dp(40);
        invitePanel.setLayoutParams(params);
        container.addView(invitePanel);
    }
    TintImageView inviteIcon = new TintImageView(getActivity());
    inviteIcon.setTint(color);
    inviteIcon.setResource(icon);
    {
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(Screen.dp(52), Screen.dp(52));
        layoutParams.leftMargin = Screen.dp(6);
        layoutParams.topMargin = Screen.dp(6);
        layoutParams.bottomMargin = Screen.dp(6);
        layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
        invitePanel.addView(inviteIcon, layoutParams);
    }
    TextView inviteText = new TextView(getActivity());
    inviteText.setText(getString(text).replace("{appName}", ActorSDK.sharedActor().getAppName()));
    inviteText.setTextColor(color);
    inviteText.setPadding(Screen.dp(72), 0, Screen.dp(8), 0);
    inviteText.setTextSize(16);
    inviteText.setSingleLine(true);
    inviteText.setEllipsize(TextUtils.TruncateAt.END);
    inviteText.setTypeface(Fonts.medium());
    {
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = Gravity.CENTER_VERTICAL;
        layoutParams.topMargin = Screen.dp(16);
        layoutParams.bottomMargin = Screen.dp(16);
        invitePanel.addView(inviteText, layoutParams);
    }
    if (!isLast) {
        View div = new View(getActivity());
        div.setBackgroundColor(ActorSDK.sharedActor().style.getContactDividerColor());
        {
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.div_size));
            layoutParams.gravity = Gravity.BOTTOM;
            layoutParams.leftMargin = Screen.dp(72);
            invitePanel.addView(div, layoutParams);
        }
    }
    if (isHeader) {
        addHeaderView(container);
    } else {
        addFooterView(container);
    }
}
Also used : FrameLayout(android.widget.FrameLayout) TintImageView(im.actor.sdk.view.TintImageView) TextView(android.widget.TextView) SearchView(android.support.v7.widget.SearchView) TintImageView(im.actor.sdk.view.TintImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 9 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.

the class LayoutManager method findFirstVisibleItem.

/**
     * Find the position of the first visible item.
     *
     * @return Position of first visible item.
     */
public View findFirstVisibleItem() {
    SectionData sd = new SectionData(this, getChildAt(0));
    final SectionLayoutManager slm = getSlm(sd);
    View firstVisibleView = slm.getFirstVisibleView(sd.firstPosition, false);
    int position = getPosition(firstVisibleView);
    if (position > sd.firstPosition + 1 || position == sd.firstPosition) {
        return firstVisibleView;
    }
    View first = findAttachedHeaderOrFirstViewForSection(sd.firstPosition, 0, Direction.START);
    if (first == null) {
        return firstVisibleView;
    }
    if (getDecoratedBottom(first) <= getDecoratedTop(firstVisibleView)) {
        return first;
    }
    LayoutParams firstParams = (LayoutParams) first.getLayoutParams();
    if ((!firstParams.isHeaderInline() || firstParams.isHeaderOverlay()) && getDecoratedTop(first) == getDecoratedTop(firstVisibleView)) {
        return first;
    }
    return firstVisibleView;
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 10 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.

the class LayoutManager method getFractionOfContentAbove.

private float getFractionOfContentAbove(RecyclerView.State state, boolean ignorePosition) {
    float fractionOffscreen = 0;
    View child = getChildAt(0);
    final int anchorPosition = getPosition(child);
    int numBeforeAnchor = 0;
    float top = getDecoratedTop(child);
    float bottom = getDecoratedBottom(child);
    if (bottom < 0) {
        fractionOffscreen = 1;
    } else if (0 <= top) {
        fractionOffscreen = 0;
    } else {
        float height = getDecoratedMeasuredHeight(child);
        fractionOffscreen = -top / height;
    }
    SectionData sd = new SectionData(this, child);
    if (sd.headerParams.isHeader && sd.headerParams.isHeaderInline()) {
        // Header must not be stickied as it is not attached after section items.
        return fractionOffscreen;
    }
    // Run through all views in the section and add up values offscreen.
    int firstPosition = -1;
    SparseArray<Boolean> positionsOffscreen = new SparseArray<>();
    for (int i = 1; i < getChildCount(); i++) {
        child = getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (!sd.sameSectionManager(lp)) {
            break;
        }
        final int position = getPosition(child);
        if (!ignorePosition && position < anchorPosition) {
            numBeforeAnchor += 1;
        }
        top = getDecoratedTop(child);
        bottom = getDecoratedBottom(child);
        if (bottom < 0) {
            fractionOffscreen += 1;
        } else if (0 <= top) {
            continue;
        } else {
            float height = getDecoratedMeasuredHeight(child);
            fractionOffscreen += -top / height;
        }
        if (!lp.isHeader) {
            if (firstPosition == -1) {
                firstPosition = position;
            }
            positionsOffscreen.put(position, true);
        }
    }
    return fractionOffscreen - numBeforeAnchor - getSlm(sd).howManyMissingAbove(firstPosition, positionsOffscreen);
}
Also used : SparseArray(android.util.SparseArray) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

View (android.view.View)140 RecyclerView (android.support.v7.widget.RecyclerView)127 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)38 ViewGroup (android.view.ViewGroup)33 LinearLayout (android.widget.LinearLayout)27 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)17 Paint (android.graphics.Paint)15 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 BindView (butterknife.BindView)12 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)11 Toolbar (android.support.v7.widget.Toolbar)11 Rect (android.graphics.Rect)9 EditText (android.widget.EditText)9 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)9 AdapterView (android.widget.AdapterView)8 RelativeLayout (android.widget.RelativeLayout)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7