Search in sources :

Example 1 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project UltimateAndroid by cymcsg.

the class BaseLayoutManager method generateLayoutParams.

@Override
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
    final LayoutParams lanedLp = new LayoutParams((MarginLayoutParams) lp);
    if (isVertical()) {
        lanedLp.width = LayoutParams.MATCH_PARENT;
        lanedLp.height = lp.height;
    } else {
        lanedLp.width = lp.width;
        lanedLp.height = LayoutParams.MATCH_PARENT;
    }
    return lanedLp;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 2 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project UltimateAndroid by cymcsg.

the class SpannableGridLayoutManager method generateLayoutParams.

@Override
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
    final LayoutParams spannableLp = new LayoutParams((MarginLayoutParams) lp);
    spannableLp.width = LayoutParams.MATCH_PARENT;
    spannableLp.height = LayoutParams.MATCH_PARENT;
    if (lp instanceof LayoutParams) {
        final LayoutParams other = (LayoutParams) lp;
        if (isVertical()) {
            spannableLp.colSpan = Math.max(1, Math.min(other.colSpan, getLaneCount()));
            spannableLp.rowSpan = Math.max(1, other.rowSpan);
        } else {
            spannableLp.colSpan = Math.max(1, other.colSpan);
            spannableLp.rowSpan = Math.max(1, Math.min(other.rowSpan, getLaneCount()));
        }
    }
    return spannableLp;
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 3 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project SmartAndroidSource by jaychou2012.

the class AbstractAQuery method margin.

/**
	 * Set the margin of a view. Notes all parameters are in DIP, not in pixel.
	 *
	 * @param leftDip the left dip
	 * @param topDip the top dip
	 * @param rightDip the right dip
	 * @param bottomDip the bottom dip
	 * @return self
	 */
public T margin(float leftDip, float topDip, float rightDip, float bottomDip) {
    if (view != null) {
        LayoutParams lp = view.getLayoutParams();
        if (lp instanceof MarginLayoutParams) {
            Context context = getContext();
            int left = AQUtility.dip2pixel(context, leftDip);
            int top = AQUtility.dip2pixel(context, topDip);
            int right = AQUtility.dip2pixel(context, rightDip);
            int bottom = AQUtility.dip2pixel(context, bottomDip);
            ((MarginLayoutParams) lp).setMargins(left, top, right, bottom);
            view.setLayoutParams(lp);
        }
    }
    return self();
}
Also used : Context(android.content.Context) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) Paint(android.graphics.Paint)

Example 4 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project android-demos by novoda.

the class LeftNavBar method setTopMargin.

private void setTopMargin(View view, int margin) {
    MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams();
    params.topMargin = margin;
    view.setLayoutParams(params);
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 5 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project platform_frameworks_base by android.

the class VolumeDialog method updateDialogBottomMarginH.

private void updateDialogBottomMarginH() {
    final long diff = System.currentTimeMillis() - mCollapseTime;
    final boolean collapsing = mCollapseTime != 0 && diff < getConservativeCollapseDuration();
    final ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams();
    final int bottomMargin = collapsing ? mDialogContentView.getHeight() : mContext.getResources().getDimensionPixelSize(R.dimen.volume_dialog_margin_bottom);
    if (bottomMargin != mlp.bottomMargin) {
        if (D.BUG)
            Log.d(TAG, "bottomMargin " + mlp.bottomMargin + " -> " + bottomMargin);
        mlp.bottomMargin = bottomMargin;
        mDialogView.setLayoutParams(mlp);
    }
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ViewGroup(android.view.ViewGroup) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) SuppressLint(android.annotation.SuppressLint)

Aggregations

MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)40 ViewGroup (android.view.ViewGroup)15 LayoutParams (android.view.ViewGroup.LayoutParams)10 SuppressLint (android.annotation.SuppressLint)8 Paint (android.graphics.Paint)6 ViewInfo (com.android.ide.common.rendering.api.ViewInfo)6 Point (android.graphics.Point)5 ViewParent (android.view.ViewParent)5 ActionMenuView (android.widget.ActionMenuView)5 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)5 Context (android.content.Context)4 View (android.view.View)4 TextView (android.widget.TextView)4 TextPaint (android.text.TextPaint)3 IntentFilter (android.content.IntentFilter)2 RemoteException (android.os.RemoteException)2 RecyclerView (android.support.v7.widget.RecyclerView)2 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)2 MotionEvent (android.view.MotionEvent)2 ImageView (android.widget.ImageView)2