Search in sources :

Example 46 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project SmartNews by JavenLu.

the class LayoutManagerHelper method handleStaggeredGridNoFullSpan.

public static View handleStaggeredGridNoFullSpan(LayoutInflater inflater, @NonNull ViewGroup parent, int layoutResourceId) {
    View view = inflater.inflate(layoutResourceId, parent, false);
    if (CommonLibraryApplication.isStaggeredGridLayoutManager) {
        StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
        layoutParams.width = StaggeredGridLayoutManager.LayoutParams.MATCH_PARENT;
        layoutParams.setFullSpan(true);
        view.setLayoutParams(layoutParams);
    }
    return view;
}
Also used : StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 47 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project SmartNews by JavenLu.

the class LayoutManagerHelper method handleStaggeredGridNoFullSpan.

public static View handleStaggeredGridNoFullSpan(LayoutInflater inflater, @NonNull ViewGroup parent, int layoutResourceId) {
    View view = inflater.inflate(layoutResourceId, parent, false);
    if (CommonLibraryApplication.isStaggeredGridLayoutManager) {
        StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
        layoutParams.width = StaggeredGridLayoutManager.LayoutParams.MATCH_PARENT;
        layoutParams.setFullSpan(true);
        view.setLayoutParams(layoutParams);
    }
    return view;
}
Also used : StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 48 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project BlogSource by TeachCourse.

the class RecylerViewAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == TYPE_ITEM) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_text, null);
        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        return new ItemViewHolder(view);
    } else // type == TYPE_FOOTER 返回footerView
    if (viewType == TYPE_FOOTER) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.footerview, null);
        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        return new FooterViewHolder(view);
    }
    return null;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 49 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project FABsMenu by jahirfiquitiva.

the class FABsMenu method onLayout.

@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    switch(expandDirection) {
        case EXPAND_UP:
        case EXPAND_DOWN:
            boolean expandUp = expandDirection == EXPAND_UP;
            touchDelegateGroup.clearTouchDelegates();
            int addButtonY = expandUp ? b - t - menuButton.getMeasuredHeight() : 0;
            if (expandUp)
                addButtonY -= menuBottomMargin;
            else
                addButtonY += menuTopMargin;
            // Ensure menuButton is centered on the line where the buttons should be
            int buttonsHorizontalCenter = labelsPosition == LABELS_ON_LEFT_SIDE ? r - l - maxButtonWidth / 2 : maxButtonWidth / 2;
            buttonsHorizontalCenter -= labelsPosition == LABELS_ON_LEFT_SIDE ? menuRightMargin : -menuLeftMargin;
            int addButtonLeft = buttonsHorizontalCenter - menuButton.getMeasuredWidth() / 2;
            menuButton.layout(addButtonLeft, addButtonY, addButtonLeft + menuButton.getMeasuredWidth(), addButtonY + menuButton.getMeasuredHeight());
            int labelsOffset = maxButtonWidth / 2 + labelsMargin;
            int labelsXNearButton = labelsPosition == LABELS_ON_LEFT_SIDE ? buttonsHorizontalCenter - labelsOffset : buttonsHorizontalCenter + labelsOffset;
            int nextY = expandUp ? addButtonY - buttonSpacing : addButtonY + menuButton.getMeasuredHeight() + buttonSpacing;
            for (int i = buttonsCount - 1; i >= 0; i--) {
                final View child = getChildAt(i);
                if (child.equals(menuButton) || child.getVisibility() == GONE)
                    continue;
                int childX = buttonsHorizontalCenter - child.getMeasuredWidth() / 2;
                int childY = expandUp ? nextY - child.getMeasuredHeight() : nextY;
                child.layout(childX, childY, childX + child.getMeasuredWidth(), childY + child.getMeasuredHeight());
                float collapsedTranslation = addButtonY - childY;
                float expandedTranslation = 0f;
                child.setTranslationY(expanded ? expandedTranslation : collapsedTranslation);
                child.setAlpha(expanded ? 1f : 0f);
                LayoutParams params = (LayoutParams) child.getLayoutParams();
                params.mCollapseDir.setFloatValues(expandedTranslation, collapsedTranslation);
                params.mExpandDir.setFloatValues(collapsedTranslation, expandedTranslation);
                params.setAnimationsTarget(child);
                View label = (View) child.getTag(R.id.fab_label);
                if (label != null) {
                    int labelXAwayFromButton = labelsPosition == LABELS_ON_LEFT_SIDE ? labelsXNearButton - label.getMeasuredWidth() : labelsXNearButton + label.getMeasuredWidth();
                    int labelLeft = labelsPosition == LABELS_ON_LEFT_SIDE ? labelXAwayFromButton : labelsXNearButton;
                    int labelRight = labelsPosition == LABELS_ON_LEFT_SIDE ? labelsXNearButton : labelXAwayFromButton;
                    int labelTop = childY - labelsVerticalOffset + (child.getMeasuredHeight() - label.getMeasuredHeight()) / 2;
                    label.layout(labelLeft, labelTop, labelRight, labelTop + label.getMeasuredHeight());
                    Rect touchArea = new Rect(Math.min(childX, labelLeft), childY - buttonSpacing / 2, Math.max(childX + child.getMeasuredWidth(), labelRight), childY + child.getMeasuredHeight() + buttonSpacing / 2);
                    touchDelegateGroup.addTouchDelegate(new TouchDelegate(touchArea, child));
                    label.setTranslationY(expanded ? expandedTranslation : collapsedTranslation);
                    label.setAlpha(expanded ? 1f : 0f);
                    LayoutParams labelParams = (LayoutParams) label.getLayoutParams();
                    labelParams.mCollapseDir.setFloatValues(expandedTranslation, collapsedTranslation);
                    labelParams.mExpandDir.setFloatValues(collapsedTranslation, expandedTranslation);
                    labelParams.setAnimationsTarget(label);
                }
                nextY = expandUp ? childY - buttonSpacing : childY + child.getMeasuredHeight() + buttonSpacing;
            }
            break;
        case EXPAND_LEFT:
        case EXPAND_RIGHT:
            boolean expandLeft = expandDirection == EXPAND_LEFT;
            int addButtonX = expandLeft ? r - l - menuButton.getMeasuredWidth() : 0;
            if (expandLeft)
                addButtonX -= menuRightMargin;
            else
                addButtonX += menuLeftMargin;
            // Ensure menuButton is centered on the line where the buttons should be
            int addButtonTop = b - t - maxButtonHeight + (maxButtonHeight - menuButton.getMeasuredHeight()) / 2;
            addButtonTop -= menuBottomMargin;
            menuButton.layout(addButtonX, addButtonTop, addButtonX + menuButton.getMeasuredWidth(), addButtonTop + menuButton.getMeasuredHeight());
            int nextX = expandLeft ? addButtonX - buttonSpacing : addButtonX + menuButton.getMeasuredWidth() + buttonSpacing;
            for (int i = buttonsCount - 1; i >= 0; i--) {
                final View child = getChildAt(i);
                if (child.equals(menuButton) || child.getVisibility() == GONE)
                    continue;
                int childX = expandLeft ? nextX - child.getMeasuredWidth() : nextX;
                int childY = addButtonTop + (menuButton.getMeasuredHeight() - child.getMeasuredHeight()) / 2;
                child.layout(childX, childY, childX + child.getMeasuredWidth(), childY + child.getMeasuredHeight());
                float collapsedTranslation = addButtonX - childX;
                float expandedTranslation = 0f;
                child.setTranslationX(expanded ? expandedTranslation : collapsedTranslation);
                child.setAlpha(expanded ? 1f : 0f);
                LayoutParams params = (LayoutParams) child.getLayoutParams();
                params.mCollapseDir.setFloatValues(expandedTranslation, collapsedTranslation);
                params.mExpandDir.setFloatValues(collapsedTranslation, expandedTranslation);
                params.setAnimationsTarget(child);
                nextX = expandLeft ? childX - buttonSpacing : childX + child.getMeasuredWidth() + buttonSpacing;
            }
            break;
        default:
            // Do Nothing
            break;
    }
}
Also used : Rect(android.graphics.Rect) TouchDelegate(android.view.TouchDelegate) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 50 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project android2 by aqi00.

the class ScrollFlagActivity method initFlagSpinner.

// 初始化滚动标志的下拉框
private void initFlagSpinner() {
    ArrayAdapter<String> flagAdapter = new ArrayAdapter<String>(this, R.layout.item_select, descArray);
    flagAdapter.setDropDownViewResource(R.layout.item_dropdown);
    Spinner sp_style = findViewById(R.id.sp_flag);
    sp_style.setPrompt("请选择滚动标志");
    sp_style.setAdapter(flagAdapter);
    // 设置下拉框列表的选择监听器
    sp_style.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // 获取可折叠布局的布局参数
            LayoutParams params = (LayoutParams) ctl_title.getLayoutParams();
            // 设置布局参数中的滚动标志位
            params.setScrollFlags(flagArray[arg2]);
            // 设置可折叠布局的布局参数。注意:第三种滚动标志一定要调用setLayoutParams
            ctl_title.setLayoutParams(params);
        }

        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    sp_style.setSelection(0);
}
Also used : LayoutParams(android.support.design.widget.AppBarLayout.LayoutParams) Spinner(android.widget.Spinner) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

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