android.view.ViewGroup.MarginLayoutParams Java Examples

The following examples show how to use android.view.ViewGroup.MarginLayoutParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ToDoList   Author: LeeLulin   File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 恢复初始状态
 */
private void recovery() {

    progress.setVisibility(View.GONE);
    mBtnLogin.setVisibility(View.VISIBLE);
    mInputLayout.setVisibility(View.VISIBLE);
    mName.setVisibility(View.VISIBLE);
    mPsw.setVisibility(View.VISIBLE);

    ViewGroup.MarginLayoutParams params = (MarginLayoutParams) mInputLayout.getLayoutParams();
    params.leftMargin = 0;
    params.rightMargin = 0;
    mInputLayout.setLayoutParams(params);


    ObjectAnimator animator2 = ObjectAnimator.ofFloat(mInputLayout, "scaleX", 0.5f,1f );
    animator2.setDuration(500);
    animator2.setInterpolator(new AccelerateDecelerateInterpolator());
    animator2.start();
}
 
Example #2
Source Project: weex   Author: Laisly   File: ViewHighlightOverlays.java    License: Apache License 2.0 6 votes vote down vote up
void highlightView(View view) {
  ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
  if (layoutParams instanceof MarginLayoutParams) {
    MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams;
    mMargins.left = marginLayoutParams.leftMargin;
    mMargins.top = marginLayoutParams.topMargin;
    mMargins.right = marginLayoutParams.rightMargin;
    mMargins.bottom = marginLayoutParams.bottomMargin;
  } else {
    mMargins.left = 0;
    mMargins.top = 0;
    mMargins.right = 0;
    mMargins.bottom = 0;
  }
  mPaddings.left = view.getPaddingLeft();
  mPaddings.top = view.getPaddingTop();
  mPaddings.right = view.getPaddingRight();
  mPaddings.bottom = view.getPaddingBottom();
}
 
Example #3
Source Project: letv   Author: JackChan1999   File: MyRandomSeeFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void findView() {
    this.mOperationBarView = this.root.findViewById(2131362660);
    this.mFooterLayout = UIs.inflate(this.mActivity, R.layout.fragment_my_download_worldcup_bottom, null);
    this.mFootCloseBtn = (Button) this.mFooterLayout.findViewById(R.id.btn_close_worldcup);
    this.mNullScrollView = (ScrollView) this.root.findViewById(R.id.scrollview_tip);
    this.mNullTip = (LinearLayout) this.root.findViewById(R.id.linearlayout_tip_download);
    this.mTextOpenTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip);
    ((MarginLayoutParams) this.mTextOpenTip.getLayoutParams()).topMargin = UIs.zoomWidth(LiveType.PLAY_LIVE_OTHER);
    this.mTextOpenSubTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip_line2);
    ((MarginLayoutParams) this.mTextOpenSubTip.getLayoutParams()).topMargin = UIs.zoomWidth(9);
    this.mListView = (ListView) this.root.findViewById(2131361938);
    this.mStartAllBtn = (Button) this.mOperationBarView.findViewById(2131362659);
    this.mPauseAllBtn = (Button) this.mOperationBarView.findViewById(2131362658);
    this.mOpenWorldCupBtn = (Button) this.root.findViewById(R.id.btn_open_close);
    this.mStartAllBtn.setOnClickListener(this.onClick);
    this.mPauseAllBtn.setOnClickListener(this.onClick);
    this.mOpenWorldCupBtn.setOnClickListener(this.onClick);
    this.mFootCloseBtn.setOnClickListener(this.onClick);
    this.mDialog = new CustomLoadingDialog(this.mActivity);
    this.mDialog.setCanceledOnTouchOutside(false);
    this.rootWatchAlertLayout = (RelativeLayout) this.root.findViewById(R.id.road_watch_ball_alert_layout);
    ((TextView) this.rootWatchAlertLayout.findViewById(R.id.road_watch_ball_alert)).setText(LetvTools.getTextFromServer(DialogMsgConstantId.CONSTANT_70013, getActivity().getResources().getString(2131100080)));
    this.rootWatchAlertLayout.setOnClickListener(this.onClick);
    setText();
}
 
Example #4
Source Project: delion   Author: derry   File: BookmarkPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a new instance of the bookmarks page.
 * @param activity The activity to get context and manage fragments.
 * @param tab The tab to load urls.
 */
public BookmarkPage(Activity activity, Tab tab) {
    mActivity = activity;
    mTab = tab;
    mTitle = activity.getString(R.string.bookmarks);
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    mManager = new BookmarkManager(mActivity, false);
    Resources res = mActivity.getResources();

    MarginLayoutParams layoutParams = new MarginLayoutParams(
            MarginLayoutParams.MATCH_PARENT, MarginLayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0,
            res.getDimensionPixelSize(R.dimen.tab_strip_height)
            + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
            0, 0);
    mManager.getView().setLayoutParams(layoutParams);
    mManager.setUrlChangeListener(this);
}
 
Example #5
Source Project: glide-support   Author: TWiStErRob   File: GlidePagerFragment.java    License: The Unlicense 6 votes vote down vote up
@Override public @Nullable View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	ViewPager view = new ViewPager(getActivity()); // container.getContext() results in white on white text
	view.setId(android.R.id.list);
	view.setLayoutParams(new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

	PagerTitleStrip title = new PagerTabStrip(view.getContext());
	ViewPager.LayoutParams params = new ViewPager.LayoutParams();
	params.width = LayoutParams.MATCH_PARENT;
	params.height = LayoutParams.WRAP_CONTENT;
	params.gravity = Gravity.TOP;
	title.setLayoutParams(params);

	view.addView(title);
	return view;
}
 
Example #6
Source Project: stetho   Author: facebook   File: ViewHighlightOverlays.java    License: MIT License 6 votes vote down vote up
void highlightView(View view) {
  ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
  if (layoutParams instanceof MarginLayoutParams) {
    MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams;
    mMargins.left = marginLayoutParams.leftMargin;
    mMargins.top = marginLayoutParams.topMargin;
    mMargins.right = marginLayoutParams.rightMargin;
    mMargins.bottom = marginLayoutParams.bottomMargin;
  } else {
    mMargins.left = 0;
    mMargins.top = 0;
    mMargins.right = 0;
    mMargins.bottom = 0;
  }
  mPaddings.left = view.getPaddingLeft();
  mPaddings.top = view.getPaddingTop();
  mPaddings.right = view.getPaddingRight();
  mPaddings.bottom = view.getPaddingBottom();
}
 
Example #7
Source Project: AndroidChromium   Author: JackyAndroid   File: SnackbarView.java    License: Apache License 2.0 6 votes vote down vote up
void adjustViewPosition() {
    mParent.getWindowVisibleDisplayFrame(mCurrentVisibleRect);
    // Only update if the visible frame has changed, otherwise there will be a layout loop.
    if (!mCurrentVisibleRect.equals(mPreviousVisibleRect)) {
        mPreviousVisibleRect.set(mCurrentVisibleRect);

        int keyboardHeight = mParent.getHeight() - mCurrentVisibleRect.bottom
                + mCurrentVisibleRect.top;
        MarginLayoutParams lp = getLayoutParams();
        lp.bottomMargin = keyboardHeight;
        if (mIsTablet) {
            int margin = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_margin_tablet);
            ApiCompatibilityUtils.setMarginStart(lp, margin);
            lp.bottomMargin += margin;
            int width = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_width_tablet);
            lp.width = Math.min(width, mParent.getWidth() - 2 * margin);
        }
        mView.setLayoutParams(lp);
    }
}
 
Example #8
Source Project: EverMemo   Author: daimajia   File: MarginAnimation.java    License: MIT License 6 votes vote down vote up
public MarginAnimation(ViewGroup target, int finalLeft, int finalTop,
		int finalRight, int finalBottom) {
	this.finalBottom = finalBottom;
	this.finalTop = finalTop;
	this.finalRight = finalRight;
	this.finalLeft = finalLeft;
	originLayoutParams = (MarginLayoutParams) target.getLayoutParams();
	originBottom = originLayoutParams.bottomMargin;
	originLeft = originLayoutParams.leftMargin;
	originRight = originLayoutParams.rightMargin;
	originTop = originLayoutParams.topMargin;
	spanLeft = originLeft - this.finalLeft;
	spanRight = originRight - this.finalRight;
	spanBottom = originBottom - this.finalBottom;
	spanTop = originTop - this.finalTop;
	mTarget = target;
	setDuration(250);
}
 
Example #9
Source Project: GravityBox   Author: WrBug   File: BatteryBarView.java    License: Apache License 2.0 6 votes vote down vote up
private void updatePosition() {
    MarginLayoutParams lp = null;
    if (mContainerType == ContainerType.STATUSBAR) {
        lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        ((FrameLayout.LayoutParams)lp).gravity = mPosition == Position.TOP ? 
            Gravity.TOP : Gravity.BOTTOM;
    } else if (mContainerType == ContainerType.KEYGUARD) {
        lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        if (mPosition == Position.TOP) {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_TOP,
                    RelativeLayout.TRUE);
        } else {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
                    RelativeLayout.TRUE);
        }
    }

    if (lp != null) {
        lp.setMargins(0, mPosition == Position.TOP ? mMarginPx : 0,
                    0, mPosition == Position.BOTTOM ? mMarginPx : 0);
        setLayoutParams(lp);
    }
}
 
Example #10
Source Project: connectivity-samples   Author: android   File: JUIHelper.java    License: Apache License 2.0 5 votes vote down vote up
public void setMargins(final View view, final int left, final int top,
        final int right, final int bottom) {
    activity_.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view
                    .getLayoutParams();
            params.setMargins(left, top, right, bottom);
        }
    });
}
 
Example #11
Source Project: 365browser   Author: mogoweb   File: ApiCompatibilityUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @see android.view.ViewGroup.MarginLayoutParams#getMarginEnd()
 */
public static int getMarginEnd(MarginLayoutParams layoutParams) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return layoutParams.getMarginEnd();
    } else {
        return layoutParams.rightMargin;
    }
}
 
Example #12
Source Project: FimiX8-RE   Author: wladimir-computin   File: AbViewUtil.java    License: MIT License 5 votes vote down vote up
@SuppressLint({"NewApi"})
public static void scaleView(View view) {
    if (view instanceof TextView) {
        TextView textView = (TextView) view;
        setTextSize(textView, textView.getTextSize());
    }
    LayoutParams params = view.getLayoutParams();
    if (params != null) {
        int width = Integer.MIN_VALUE;
        int height = Integer.MIN_VALUE;
        if (!(params.width == -2 || params.width == -1)) {
            width = params.width;
        }
        if (!(params.height == -2 || params.height == -1)) {
            height = params.height;
        }
        setViewSize(view, width, height);
        setPadding(view, view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
    }
    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(), (float) view.getMinimumWidth());
        int minHeight = scaleValue(view.getContext(), (float) view.getMinimumHeight());
        view.setMinimumWidth(minWidth);
        view.setMinimumHeight(minHeight);
    }
}
 
Example #13
Source Project: android-chromium   Author: eduplus   File: ApiCompatibilityUtils.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see android.view.ViewGroup.MarginLayoutParams#getMarginEnd()
 */
public static int getMarginEnd(MarginLayoutParams layoutParams) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return layoutParams.getMarginEnd();
    } else {
        return layoutParams.rightMargin;
    }
}
 
Example #14
Source Project: FimiX8-RE   Author: wladimir-computin   File: PercentLayoutHelper.java    License: MIT License 5 votes vote down vote up
public void restoreMarginLayoutParams(MarginLayoutParams params) {
    restoreLayoutParams(params);
    params.leftMargin = this.mPreservedParams.leftMargin;
    params.topMargin = this.mPreservedParams.topMargin;
    params.rightMargin = this.mPreservedParams.rightMargin;
    params.bottomMargin = this.mPreservedParams.bottomMargin;
    MarginLayoutParamsCompat.setMarginStart(params, MarginLayoutParamsCompat.getMarginStart(this.mPreservedParams));
    MarginLayoutParamsCompat.setMarginEnd(params, MarginLayoutParamsCompat.getMarginEnd(this.mPreservedParams));
}
 
Example #15
Source Project: FimiX8-RE   Author: wladimir-computin   File: PercentLayoutHelper.java    License: MIT License 5 votes vote down vote up
public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec) {
    if (Log.isLoggable(TAG, 3)) {
        Log.d(TAG, "adjustChildren: " + this.mHost + " widthMeasureSpec: " + MeasureSpec.toString(widthMeasureSpec) + " heightMeasureSpec: " + MeasureSpec.toString(heightMeasureSpec));
    }
    int widthHint = MeasureSpec.getSize(widthMeasureSpec);
    int heightHint = MeasureSpec.getSize(heightMeasureSpec);
    if (Log.isLoggable(TAG, 3)) {
        Log.d(TAG, "widthHint = " + widthHint + " , heightHint = " + heightHint);
    }
    int N = this.mHost.getChildCount();
    for (int i = 0; i < N; i++) {
        View view = this.mHost.getChildAt(i);
        LayoutParams params = view.getLayoutParams();
        if (Log.isLoggable(TAG, 3)) {
            Log.d(TAG, "should adjust " + view + " " + params);
        }
        if (params instanceof PercentLayoutParams) {
            PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo();
            if (Log.isLoggable(TAG, 3)) {
                Log.d(TAG, "using " + info);
            }
            if (info != null) {
                supportTextSize(widthHint, heightHint, view, info);
                supportPadding(widthHint, heightHint, view, info);
                supportMinOrMaxDimesion(widthHint, heightHint, view, info);
                if (params instanceof MarginLayoutParams) {
                    info.fillMarginLayoutParams((MarginLayoutParams) params, widthHint, heightHint);
                } else {
                    info.fillLayoutParams(params, widthHint, heightHint);
                }
            }
        }
    }
}
 
Example #16
Source Project: material-components-android   Author: material-components   File: BaseTransientBottomBar.java    License: Apache License 2.0 5 votes vote down vote up
private int getTranslationYBottom() {
  int translationY = view.getHeight();
  LayoutParams layoutParams = view.getLayoutParams();
  if (layoutParams instanceof MarginLayoutParams) {
    translationY += ((MarginLayoutParams) layoutParams).bottomMargin;
  }
  return translationY;
}
 
Example #17
Source Project: MongoExplorer   Author: grennis   File: LeftMarginAnimation.java    License: MIT License 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
	super.applyTransformation(interpolatedTime, t);
	
	float diff = (mTo - mFrom) * interpolatedTime;
	
	((MarginLayoutParams)mView.getLayoutParams()).leftMargin = (int)(mFrom + diff);
	mView.requestLayout();
}
 
Example #18
Source Project: android-chromium   Author: eduplus   File: ApiCompatibilityUtils.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see android.view.ViewGroup.MarginLayoutParams#setMarginStart(int)
 */
public static void setMarginStart(MarginLayoutParams layoutParams, int start) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        layoutParams.setMarginStart(start);
    } else {
        layoutParams.leftMargin = start;
    }
}
 
Example #19
Source Project: openboard   Author: dslul   File: ViewLayoutUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #20
Source Project: LokiBoard-Android-Keylogger   Author: IceWreck   File: ViewLayoutUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static MarginLayoutParams newLayoutParam(final ViewGroup placer, final int width,
        final int height) {
    if (placer instanceof FrameLayout) {
        return new FrameLayout.LayoutParams(width, height);
    } else if (placer instanceof RelativeLayout) {
        return new RelativeLayout.LayoutParams(width, height);
    } else if (placer == null) {
        throw new NullPointerException("placer is null");
    } else {
        throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: "
                + placer.getClass().getName());
    }
}
 
Example #21
Source Project: 365browser   Author: mogoweb   File: SearchEnginePreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListView = (ListView) getView().findViewById(android.R.id.list);
    int marginTop = getActivity().getResources().getDimensionPixelSize(
            R.dimen.search_engine_list_margin_top);
    MarginLayoutParams layoutParams = (MarginLayoutParams) mListView.getLayoutParams();
    layoutParams.setMargins(0, marginTop, 0, 0);
    mListView.setLayoutParams(layoutParams);
    mListView.setAdapter(mSearchEngineAdapter);
    mListView.setDivider(null);
}
 
Example #22
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: VenvyUIUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param view
 * @return the MarginLayoutParams of a view. maybe null.
 */
public static MarginLayoutParams getViewMarginLayoutParams(View view) {

    ViewGroup.LayoutParams params = null;
    if (null != view) {
        params = view.getLayoutParams();
    }
    if (params instanceof MarginLayoutParams) {
        MarginLayoutParams marginLayoutParams = (MarginLayoutParams) params;
        return marginLayoutParams;
    }
    return null;
}
 
Example #23
Source Project: multi-column-list-adapter   Author: twotoasters   File: MultiColumnListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Update layout params for grid item view with appropriate vertical spacing since view re-use could change the spacing.
 */
private void updateGridItemLayoutParams(MultiColumnListViewHolder gridItemViewHolder, int row) {
    if (gridItemViewHolder != null) {
        View gridItemView = gridItemViewHolder.getGridItemView();
        if (gridItemView != null) {
            LayoutParams lp = gridItemView.getLayoutParams();
            if (lp instanceof MarginLayoutParams) {
                MarginLayoutParams mlp = (MarginLayoutParams) lp;
                int numRows = getCount();
                mlp.topMargin = (row == 0 ? gridItemVerticalSpacing : gridItemVerticalSpacing / 2);
                mlp.bottomMargin = (row == numRows - 1 ? gridItemVerticalSpacing : gridItemVerticalSpacing / 2);
            }
        }
    }
}
 
Example #24
Source Project: AOSP-Kayboard-7.1.2   Author: sergchil   File: ViewLayoutUtils.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #25
Source Project: Jockey   Author: marverenic   File: BindingAdapters.java    License: Apache License 2.0 5 votes vote down vote up
@BindingAdapter("android:translationYPercent")
public static void bindTranslationYPercent(View view, float percent) {
    View parent = (View) view.getParent();
    MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams();
    int remainingHeight = parent.getMeasuredHeight() - layoutParams.bottomMargin;
    view.setTranslationY(-1 * percent * remainingHeight);
}
 
Example #26
Source Project: AndroidUtilCode   Author: Blankj   File: BarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Add the top margin size equals status bar's height for view.
 *
 * @param view The view.
 */
public static void addMarginTopEqualStatusBarHeight(@NonNull View view) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    view.setTag(TAG_OFFSET);
    Object haveSetOffset = view.getTag(KEY_OFFSET);
    if (haveSetOffset != null && (Boolean) haveSetOffset) return;
    MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams();
    layoutParams.setMargins(layoutParams.leftMargin,
            layoutParams.topMargin + getStatusBarHeight(),
            layoutParams.rightMargin,
            layoutParams.bottomMargin);
    view.setTag(KEY_OFFSET, true);
}
 
Example #27
Source Project: AndroidUtilCode   Author: Blankj   File: BarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Subtract the top margin size equals status bar's height for view.
 *
 * @param view The view.
 */
public static void subtractMarginTopEqualStatusBarHeight(@NonNull View view) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    Object haveSetOffset = view.getTag(KEY_OFFSET);
    if (haveSetOffset == null || !(Boolean) haveSetOffset) return;
    MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams();
    layoutParams.setMargins(layoutParams.leftMargin,
            layoutParams.topMargin - getStatusBarHeight(),
            layoutParams.rightMargin,
            layoutParams.bottomMargin);
    view.setTag(KEY_OFFSET, false);
}
 
Example #28
Source Project: 365browser   Author: mogoweb   File: ApiCompatibilityUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @see android.view.ViewGroup.MarginLayoutParams#setMarginStart(int)
 */
public static void setMarginStart(MarginLayoutParams layoutParams, int start) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        layoutParams.setMarginStart(start);
    } else {
        layoutParams.leftMargin = start;
    }
}
 
Example #29
Source Project: Indic-Keyboard   Author: smc   File: ViewLayoutUtils.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #30
Source Project: MongoExplorer   Author: grennis   File: MultiPaneActivity.java    License: MIT License 5 votes vote down vote up
private void animateFromOffscreenToLeftPane(View view) {
   	((MarginLayoutParams)view.getLayoutParams()).width = mLeftPaneWidth;
   	view.requestLayout();

	Animation animation = new LeftMarginAnimation(view, -mLeftPaneWidth, 0);
	view.startAnimation(animation);
}