本文整理汇总了Java中android.support.v4.view.MarginLayoutParamsCompat类的典型用法代码示例。如果您正苦于以下问题:Java MarginLayoutParamsCompat类的具体用法?Java MarginLayoutParamsCompat怎么用?Java MarginLayoutParamsCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MarginLayoutParamsCompat类属于android.support.v4.view包,在下文中一共展示了MarginLayoutParamsCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromFlexView
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
public static FlexItem fromFlexView(View view, int index) {
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams();
FlexItem flexItem = new FlexItem();
flexItem.index = index;
flexItem.order = lp.order;
flexItem.flexGrow = lp.flexGrow;
flexItem.flexShrink = lp.flexShrink;
flexItem.alignSelf = lp.alignSelf;
flexItem.flexBasisPercent = lp.flexBasisPercent;
flexItem.width = Util.pixelToDp(view.getContext(), lp.width);
flexItem.height = Util.pixelToDp(view.getContext(), lp.height);
flexItem.topMargin = lp.topMargin;
flexItem.startMargin = MarginLayoutParamsCompat.getMarginStart(lp);
flexItem.endMargin = MarginLayoutParamsCompat.getMarginEnd(lp);
flexItem.bottomMargin = lp.bottomMargin;
flexItem.paddingTop = view.getPaddingTop();
flexItem.paddingStart = ViewCompat.getPaddingStart(view);
flexItem.paddingEnd = ViewCompat.getPaddingEnd(view);
flexItem.paddingBottom = view.getPaddingBottom();
return flexItem;
}
示例2: addFloatingActionButton
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
private void addFloatingActionButton() {
final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab);
int bottomOfQuestionView = findViewById(R.id.question_view).getBottom();
final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize,
Gravity.END | Gravity.TOP);
final int halfAFab = fabSize / 2;
fabLayoutParams.setMargins(0, // left
bottomOfQuestionView - halfAFab, //top
0, // right
mSpacingDouble); // bottom
MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, mSpacingDouble);
if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
// Account for the fab's emulated shadow.
fabLayoutParams.topMargin -= (mSubmitAnswer.getPaddingTop() / 2);
}
addView(mSubmitAnswer, fabLayoutParams);
}
示例3: onLayout
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
if (ViewCompat.getLayoutDirection(this) == 0) {}
for (boolean bool = true;; bool = false)
{
int i = getWidth();
ViewGroup.MarginLayoutParams localMarginLayoutParams1 = (ViewGroup.MarginLayoutParams)this.mSubtitle.getLayoutParams();
int j = this.mSubtitle.getMeasuredWidth();
int k = PlayUtils.getViewLeftFromParentStart(i, j, bool, MarginLayoutParamsCompat.getMarginStart(localMarginLayoutParams1));
this.mSubtitle.layout(k, 0, k + j, this.mSubtitle.getMeasuredHeight());
ViewGroup.MarginLayoutParams localMarginLayoutParams2 = (ViewGroup.MarginLayoutParams)this.mLabel.getLayoutParams();
int m = this.mSubtitle.getBaseline() - this.mLabel.getBaseline();
int n = this.mLabel.getMeasuredWidth();
int i1 = PlayUtils.getViewLeftFromParentEnd(i, n, bool, MarginLayoutParamsCompat.getMarginEnd(localMarginLayoutParams2));
this.mLabel.layout(i1, m, i1 + n, m + this.mLabel.getMeasuredHeight());
return;
}
}
示例4: onLayout
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
if (ViewCompat.getLayoutDirection(this) == 0) {}
for (boolean bool = true;; bool = false)
{
int i = getWidth();
int j = ViewCompat.getPaddingStart(this);
int k = MarginLayoutParamsCompat.getMarginStart((ViewGroup.MarginLayoutParams)this.mPromoContentView.getLayoutParams()) + getPaddingLeft();
int m = this.mPromoContentView.getMeasuredWidth();
int n = PlayUtils.getViewLeftFromParentStart(i, m, bool, k);
int i1 = getPaddingTop();
int i2 = i1 + this.mPromoContentView.getMeasuredHeight();
int i3 = i2 - this.mDefaultCardInset;
int i4 = this.mCardView.getMeasuredWidth();
int i5 = PlayUtils.getViewLeftFromParentStart(i, i4, bool, j);
this.mPromoContentView.layout(n, i1, n + m, i2);
if (this.mSeparator.getVisibility() == 0)
{
this.mSeparator.layout(0, i2, getMeasuredWidth(), i2 + this.mSeparator.getMeasuredHeight());
i3 += this.mSeparator.getMeasuredHeight();
}
this.mCardView.layout(i5, i3, i5 + i4, i3 + this.mCardView.getMeasuredHeight());
return;
}
}
示例5: getMarginStart
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
static int getMarginStart(View v) {
if (v == null) {
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginStart(lp);
}
示例6: getMarginEnd
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
static int getMarginEnd(View v) {
if (v == null) {
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginEnd(lp);
}
示例7: getMarginHorizontally
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
static int getMarginHorizontally(View v) {
if (v == null) {
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
示例8: restoreMarginLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
/**
* Restores the original dimensions and margins after they were changed for percentage based
* values. You should call this method only if you previously called
* {@link PercentLayoutHelper.PercentLayoutInfo#fillMarginLayoutParams(View, ViewGroup.MarginLayoutParams, int, int)}.
*/
public void restoreMarginLayoutParams(ViewGroup.MarginLayoutParams params) {
restoreLayoutParams(params);
params.leftMargin = mPreservedParams.leftMargin;
params.topMargin = mPreservedParams.topMargin;
params.rightMargin = mPreservedParams.rightMargin;
params.bottomMargin = mPreservedParams.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(params,
MarginLayoutParamsCompat.getMarginStart(mPreservedParams));
MarginLayoutParamsCompat.setMarginEnd(params,
MarginLayoutParamsCompat.getMarginEnd(mPreservedParams));
}
示例9: setTabButtonVisible
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
public void setTabButtonVisible(boolean visible) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)
mSendText.getLayoutParams();
if (visible) {
MarginLayoutParamsCompat.setMarginStart(layoutParams, 0);
mTabIcon.setVisibility(View.VISIBLE);
} else {
MarginLayoutParamsCompat.setMarginStart(layoutParams, mContext.getResources()
.getDimensionPixelSize(R.dimen.message_edit_text_margin_left));
mTabIcon.setVisibility(View.GONE);
}
mSendText.setLayoutParams(layoutParams);
}
示例10: getMarginHorizontally
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
static int getMarginHorizontally(View v) {
if (v == null) {
return 0;
}
MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat
.getMarginEnd(lp);
}
示例11: restoreMarginLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
/**
* Restores original dimensions and margins after they were changed for percentage based
* values. Calling this method only makes sense if you previously called
* {@link PercentLayoutInfo#fillMarginLayoutParams}.
*/
public void restoreMarginLayoutParams(ViewGroup.MarginLayoutParams params) {
restoreLayoutParams(params);
params.leftMargin = mPreservedParams.leftMargin;
params.topMargin = mPreservedParams.topMargin;
params.rightMargin = mPreservedParams.rightMargin;
params.bottomMargin = mPreservedParams.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(params,
MarginLayoutParamsCompat.getMarginStart(mPreservedParams));
MarginLayoutParamsCompat.setMarginEnd(params,
MarginLayoutParamsCompat.getMarginEnd(mPreservedParams));
}
示例12: toLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
public FlexboxLayout.LayoutParams toLayoutParams(Context context) {
FlexboxLayout.LayoutParams lp = new FlexboxLayout.LayoutParams(
Util.dpToPixel(context, width),
Util.dpToPixel(context, height));
lp.order = order;
lp.flexGrow = flexGrow;
lp.flexShrink = flexShrink;
lp.alignSelf = alignSelf;
lp.flexBasisPercent = flexBasisPercent;
lp.topMargin = topMargin;
MarginLayoutParamsCompat.setMarginStart(lp, startMargin);
MarginLayoutParamsCompat.setMarginEnd(lp, endMargin);
lp.bottomMargin = bottomMargin;
return lp;
}
示例13: restoreMarginLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
/**
* Restores original dimensions and margins after they were changed for percentage based
* values. Calling this method only makes sense if you previously called
* {@link PercentLayoutInfo#fillMarginLayoutParams}.
*/
public void restoreMarginLayoutParams(ViewGroup.MarginLayoutParams params)
{
restoreLayoutParams(params);
params.leftMargin = mPreservedParams.leftMargin;
params.topMargin = mPreservedParams.topMargin;
params.rightMargin = mPreservedParams.rightMargin;
params.bottomMargin = mPreservedParams.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(params,
MarginLayoutParamsCompat.getMarginStart(mPreservedParams));
MarginLayoutParamsCompat.setMarginEnd(params,
MarginLayoutParamsCompat.getMarginEnd(mPreservedParams));
}
示例14: restoreMarginLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
/**
* Restores original dimensions and margins after they were changed for percentage based
* values. Calling this method only makes sense if you previously called
* {@link PercentLayoutHelper.PercentLayoutInfo#fillMarginLayoutParams}.
*/
public void restoreMarginLayoutParams(ViewGroup.MarginLayoutParams params)
{
restoreLayoutParams(params);
params.leftMargin = mPreservedParams.leftMargin;
params.topMargin = mPreservedParams.topMargin;
params.rightMargin = mPreservedParams.rightMargin;
params.bottomMargin = mPreservedParams.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(params,
MarginLayoutParamsCompat.getMarginStart(mPreservedParams));
MarginLayoutParamsCompat.setMarginEnd(params,
MarginLayoutParamsCompat.getMarginEnd(mPreservedParams));
}
开发者ID:luozhimin0918,项目名称:android-percent-support-extend-master,代码行数:18,代码来源:PercentLayoutHelper.java
示例15: getMarginStart
import android.support.v4.view.MarginLayoutParamsCompat; //导入依赖的package包/类
static int getMarginStart(View v)
{
if (v == null)
{
return 0;
}
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
return MarginLayoutParamsCompat.getMarginStart(lp);
}