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);
}
}
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();
}
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);
}
}
}
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);
}
}
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);
}
}
Aggregations