Search in sources :

Example 21 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class ViewLayoutUtils method placeViewAt.

public static void placeViewAt(final View view, final int x, final int y, final int w, final int h) {
    final ViewGroup.LayoutParams lp = view.getLayoutParams();
    if (lp instanceof MarginLayoutParams) {
        final MarginLayoutParams marginLayoutParams = (MarginLayoutParams) lp;
        marginLayoutParams.width = w;
        marginLayoutParams.height = h;
        marginLayoutParams.setMargins(x, y, 0, 0);
    }
}
Also used : ViewGroup(android.view.ViewGroup) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 22 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project ABPlayer by winkstu.

the class BiliVideoViewActivity method loadVPlayerPrefs.

private void loadVPlayerPrefs() {
    if (!isInitialized())
        return;
    vPlayer.setBuffer(VP.DEFAULT_BUF_SIZE);
    vPlayer.setVideoQuality(VP.DEFAULT_VIDEO_QUALITY);
    vPlayer.setDeinterlace(VP.DEFAULT_DEINTERLACE);
    vPlayer.setVolume(VP.DEFAULT_STEREO_VOLUME, VP.DEFAULT_STEREO_VOLUME);
    vPlayer.setSubEncoding(VP.DEFAULT_SUB_ENCODING);
    MarginLayoutParams lp = (MarginLayoutParams) mSubtitleContainer.getLayoutParams();
    lp.bottomMargin = (int) VP.DEFAULT_SUB_POS;
    mSubtitleContainer.setLayoutParams(lp);
    vPlayer.setSubShown(mSubShown);
    setTextViewStyle(mSubtitleText);
    if (!TextUtils.isEmpty(mSubPath))
        vPlayer.setSubPath(mSubPath);
    if (mVideoView != null && isInitialized())
        setVideoLayout();
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 23 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project JustAndroid by chinaltz.

the class AbViewUtil method setMargin.

/**
	 * 设置 PX margin.
	 * 
	 * @param view the view
	 * @param left the left margin in pixels
	 * @param top the top margin in pixels
	 * @param right the right margin in pixels
	 * @param bottom the bottom margin in pixels
	 */
public static void setMargin(View view, int left, int top, int right, int bottom) {
    int scaledLeft = scaleValue(view.getContext(), left);
    int scaledTop = scaleValue(view.getContext(), top);
    int scaledRight = scaleValue(view.getContext(), right);
    int scaledBottom = scaleValue(view.getContext(), bottom);
    if (view.getLayoutParams() instanceof MarginLayoutParams) {
        MarginLayoutParams mMarginLayoutParams = (MarginLayoutParams) view.getLayoutParams();
        if (mMarginLayoutParams != null) {
            if (left != INVALID) {
                mMarginLayoutParams.leftMargin = scaledLeft;
            }
            if (right != INVALID) {
                mMarginLayoutParams.rightMargin = scaledRight;
            }
            if (top != INVALID) {
                mMarginLayoutParams.topMargin = scaledTop;
            }
            if (bottom != INVALID) {
                mMarginLayoutParams.bottomMargin = scaledBottom;
            }
            view.setLayoutParams(mMarginLayoutParams);
        }
    }
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 24 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project JustAndroid by chinaltz.

the class AbViewUtil method scaleView.

/**
     * 按比例缩放View,以布局中的尺寸为基准
     * @param view
     */
@SuppressLint("NewApi")
public static void scaleView(View view) {
    if (!isNeedScale(view)) {
        return;
    }
    if (view instanceof TextView) {
        TextView textView = (TextView) view;
        setTextSize(textView, textView.getTextSize());
    }
    ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) view.getLayoutParams();
    if (null != params) {
        int width = INVALID;
        int height = INVALID;
        if (params.width != ViewGroup.LayoutParams.WRAP_CONTENT && params.width != ViewGroup.LayoutParams.MATCH_PARENT) {
            width = params.width;
        }
        if (params.height != ViewGroup.LayoutParams.WRAP_CONTENT && params.height != ViewGroup.LayoutParams.MATCH_PARENT) {
            height = params.height;
        }
        //size
        setViewSize(view, width, height);
        // Padding
        setPadding(view, view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
    }
    // Margin
    if (view.getLayoutParams() instanceof MarginLayoutParams) {
        MarginLayoutParams mMarginLayoutParams = (MarginLayoutParams) view.getLayoutParams();
        if (mMarginLayoutParams != null) {
            setMargin(view, mMarginLayoutParams.leftMargin, mMarginLayoutParams.topMargin, mMarginLayoutParams.rightMargin, mMarginLayoutParams.bottomMargin);
        }
    }
    if (VERSION.SDK_INT >= 16) {
        //最大最小宽高
        int minWidth = scaleValue(view.getContext(), view.getMinimumWidth());
        int minHeight = scaleValue(view.getContext(), view.getMinimumHeight());
        view.setMinimumWidth(minWidth);
        view.setMinimumHeight(minHeight);
    }
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 25 with MarginLayoutParams

use of android.view.ViewGroup.MarginLayoutParams in project android_frameworks_base by crdroidandroid.

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