本文整理汇总了Java中android.support.v4.view.MarginLayoutParamsCompat.setMarginStart方法的典型用法代码示例。如果您正苦于以下问题:Java MarginLayoutParamsCompat.setMarginStart方法的具体用法?Java MarginLayoutParamsCompat.setMarginStart怎么用?Java MarginLayoutParamsCompat.setMarginStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.MarginLayoutParamsCompat
的用法示例。
在下文中一共展示了MarginLayoutParamsCompat.setMarginStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: 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);
}
示例3: 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));
}
示例4: 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;
}
示例5: 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));
}
示例6: 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
示例7: loadImages
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
private ImageView[] loadImages(ImageWithCaptionOuterClass.ImageWithCaption[] paramArrayOfImageWithCaption, int paramInt1, int paramInt2, int paramInt3, boolean paramBoolean1, boolean paramBoolean2)
{
ArrayList localArrayList = new ArrayList(paramArrayOfImageWithCaption.length);
HashSet localHashSet = new HashSet(paramArrayOfImageWithCaption.length);
int i = paramInt1;
int j = paramArrayOfImageWithCaption.length;
for (int k = 0; k < j; k++)
{
ImageWithCaptionOuterClass.ImageWithCaption localImageWithCaption = paramArrayOfImageWithCaption[k];
if (!localHashSet.contains(localImageWithCaption.imageUri))
{
localHashSet.add(localImageWithCaption.imageUri);
ImageWithCaptionView localImageWithCaptionView = new ImageWithCaptionView(getContext());
if (Build.VERSION.SDK_INT >= 11) {
localImageWithCaptionView.setLayerType(2, null);
}
localImageWithCaptionView.setId(i);
RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(paramInt2, paramInt3);
if ((!paramBoolean1) && (!paramBoolean2) && (i > paramInt1))
{
MarginLayoutParamsCompat.setMarginStart(localLayoutParams, this.mSpacingBetweenCardImages);
localLayoutParams.addRule(WalletUiUtils.sanitizeRelativeLayoutVerb(17), i - 1);
}
addView(localImageWithCaptionView, localLayoutParams);
if ((PaymentUtils.isEmbeddedImageUri(localImageWithCaption.imageUri)) && (PaymentUtils.getEmbeddedImageId(localImageWithCaption.imageUri) == 27)) {
throw new IllegalArgumentException("Requesting placeholder network logo when not supported");
}
localImageWithCaptionView.setImageWithCaption(localImageWithCaption, PaymentUtils.getImageLoader(getContext().getApplicationContext()), ((Boolean)G.images.useWebPForFife.get()).booleanValue());
localImageWithCaptionView.setFadeIn(true);
localImageWithCaptionView.setErrorImageResId(R.drawable.wallet_im_card_resolved_generic);
localImageWithCaptionView.setTag(localImageWithCaption);
localArrayList.add(localImageWithCaptionView);
i++;
}
}
return (ImageView[])localArrayList.toArray(new ImageView[localArrayList.size()]);
}
示例8: moveIconToStart
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
public final void moveIconToStart()
{
if (this.mUiFieldView == null) {
throw new IllegalStateException("This should not be called before setting the contents.");
}
removeView(this.mTooltipIcon);
super.addView(this.mTooltipIcon, 0);
LinearLayout.LayoutParams localLayoutParams1 = (LinearLayout.LayoutParams)this.mUiFieldView.getLayoutParams();
LinearLayout.LayoutParams localLayoutParams2 = (LinearLayout.LayoutParams)this.mTooltipIcon.getLayoutParams();
MarginLayoutParamsCompat.setMarginEnd(localLayoutParams1, MarginLayoutParamsCompat.getMarginEnd(localLayoutParams2));
MarginLayoutParamsCompat.setMarginEnd(localLayoutParams2, MarginLayoutParamsCompat.getMarginStart(localLayoutParams2));
MarginLayoutParamsCompat.setMarginStart(localLayoutParams2, MarginLayoutParamsCompat.getMarginStart(localLayoutParams1));
MarginLayoutParamsCompat.setMarginStart(localLayoutParams1, 0);
}
示例9: setContent
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
public final void setContent(View paramView, TooltipOuterClass.Tooltip paramTooltip, ImageLoader paramImageLoader)
{
if (this.mUiFieldView != null) {
throw new IllegalStateException("setContent should only be called once.");
}
if (!(paramView instanceof TextView)) {
throw new IllegalArgumentException("Tooltips are only supported for text and date UI fields.");
}
this.mUiFieldView = paramView;
super.addView(paramView);
LinearLayout.LayoutParams localLayoutParams1 = (LinearLayout.LayoutParams)paramView.getLayoutParams();
localLayoutParams1.width = 0;
localLayoutParams1.weight = 1.0F;
this.mUiFieldView.setOnFocusChangeListener(this);
this.mTooltip = paramTooltip;
Context localContext = getContext();
int[] arrayOfInt = new int[2];
arrayOfInt[0] = R.attr.uicFormTooltipIconSize;
arrayOfInt[1] = R.attr.uicClickableBackground;
TypedArray localTypedArray = localContext.obtainStyledAttributes(arrayOfInt);
int i = localTypedArray.getDimensionPixelSize(0, 0);
int j = localTypedArray.getResourceId(1, 0);
localTypedArray.recycle();
this.mTooltipIcon = new ImageWithCaptionView(getContext());
LinearLayout.LayoutParams localLayoutParams2 = new LinearLayout.LayoutParams(i, i);
localLayoutParams2.gravity = 17;
MarginLayoutParamsCompat.setMarginStart(localLayoutParams2, getResources().getDimensionPixelSize(R.dimen.wallet_uic_margin_touchable));
MarginLayoutParamsCompat.setMarginEnd(localLayoutParams2, MarginLayoutParamsCompat.getMarginEnd(localLayoutParams1));
MarginLayoutParamsCompat.setMarginEnd(localLayoutParams1, 0);
addView(this.mTooltipIcon, localLayoutParams2);
this.mTooltipIcon.setImageWithCaption(paramTooltip.icon, paramImageLoader, ((Boolean)G.images.useWebPForFife.get()).booleanValue());
this.mTooltipIcon.setBackgroundResource(j);
updateIconVisibility(false);
this.mTooltipIcon.setOnClickListener(this);
}
示例10: fillMarginLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
/**
* Fills {@code ViewGroup.MarginLayoutParams} dimensions and margins based on percentage
* values.
*/
public void fillMarginLayoutParams(ViewGroup.MarginLayoutParams params, int widthHint,
int heightHint) {
fillLayoutParams(params, widthHint, heightHint);
// Preserver the original margins, so we can restore them after the measure step.
mPreservedParams.leftMargin = params.leftMargin;
mPreservedParams.topMargin = params.topMargin;
mPreservedParams.rightMargin = params.rightMargin;
mPreservedParams.bottomMargin = params.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(mPreservedParams,
MarginLayoutParamsCompat.getMarginStart(params));
MarginLayoutParamsCompat.setMarginEnd(mPreservedParams,
MarginLayoutParamsCompat.getMarginEnd(params));
if (leftMarginPercent >= 0) {
params.leftMargin = (int) (widthHint * leftMarginPercent);
}
if (topMarginPercent >= 0) {
params.topMargin = (int) (heightHint * topMarginPercent);
}
if (rightMarginPercent >= 0) {
params.rightMargin = (int) (widthHint * rightMarginPercent);
}
if (bottomMarginPercent >= 0) {
params.bottomMargin = (int) (heightHint * bottomMarginPercent);
}
if (startMarginPercent >= 0) {
MarginLayoutParamsCompat.setMarginStart(params,
(int) (widthHint * startMarginPercent));
}
if (endMarginPercent >= 0) {
MarginLayoutParamsCompat.setMarginEnd(params,
(int) (widthHint * endMarginPercent));
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "after fillMarginLayoutParams: (" + params.width + ", " + params.height
+ ")");
}
}
示例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 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));
}
示例12: 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));
}
示例13: applyXmlAttributes
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
private void applyXmlAttributes(AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
final TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.FloatingSearchView, defStyleAttr, defStyleRes);
// Search bar width
View suggestionsContainer = findViewById(R.id.fsv_suggestions_container);
int searchBarWidth = a.getDimensionPixelSize(R.styleable.FloatingSearchView_fsv_searchBarWidth,
mSearchContainer.getLayoutParams().width);
mSearchContainer.getLayoutParams().width = searchBarWidth;
suggestionsContainer.getLayoutParams().width = searchBarWidth;
// Divider
mDivider.setBackgroundDrawable(a.getDrawable(R.styleable.FloatingSearchView_android_divider));
int dividerHeight = a.getDimensionPixelSize(R.styleable.FloatingSearchView_android_dividerHeight, -1);
MarginLayoutParams dividerLP = (MarginLayoutParams) mDivider.getLayoutParams();
if(mDivider.getBackground() != null && dividerHeight != -1)
dividerLP.height = dividerHeight;
float maxShadowSize = mSearchBackground.getMaxShadowSize();
float cornerRadius = mSearchBackground.getCornerRadius();
int horizontalPadding = (int) (RoundRectDrawableWithShadow.calculateHorizontalPadding(
maxShadowSize, cornerRadius, false) + .5f);
dividerLP.setMargins(horizontalPadding, dividerLP.topMargin, horizontalPadding, dividerLP.bottomMargin);
mDivider.setLayoutParams(dividerLP);
// Content inset
MarginLayoutParams searchParams = (MarginLayoutParams) mSearchInput.getLayoutParams();
int contentInsetStart = a.getDimensionPixelSize(R.styleable.FloatingSearchView_contentInsetStart,
MarginLayoutParamsCompat.getMarginStart(searchParams));
int contentInsetEnd = a.getDimensionPixelSize(R.styleable.FloatingSearchView_contentInsetEnd,
MarginLayoutParamsCompat.getMarginEnd(searchParams));
MarginLayoutParamsCompat.setMarginStart(searchParams, contentInsetStart);
MarginLayoutParamsCompat.setMarginEnd(searchParams, contentInsetEnd);
// anything else
setLogo(a.getDrawable(R.styleable.FloatingSearchView_logo));
setContentBackgroundColor(a.getColor(R.styleable.FloatingSearchView_fsv_contentBackgroundColor, DEFAULT_CONTENT_COLOR));
setRadius(a.getDimensionPixelSize(R.styleable.FloatingSearchView_fsv_cornerRadius, ViewUtils.dpToPx(DEFAULT_RADIUS)));
inflateMenu(a.getResourceId(R.styleable.FloatingSearchView_fsv_menu, 0));
setPopupTheme(a.getResourceId(R.styleable.FloatingSearchView_popupTheme, 0));
setHint(a.getString(R.styleable.FloatingSearchView_android_hint));
setIcon(a.getDrawable(R.styleable.FloatingSearchView_fsv_icon));
a.recycle();
}
示例14: fillMarginLayoutParams
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
/**
* Fills {@code ViewGroup.MarginLayoutParams} dimensions and margins based on percentage
* values.
*/
public void fillMarginLayoutParams(View view, ViewGroup.MarginLayoutParams params,
int widthHint, int heightHint) {
fillLayoutParams(params, widthHint, heightHint);
// Preserve the original margins, so we can restore them after the measure step.
mPreservedParams.leftMargin = params.leftMargin;
mPreservedParams.topMargin = params.topMargin;
mPreservedParams.rightMargin = params.rightMargin;
mPreservedParams.bottomMargin = params.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(mPreservedParams,
MarginLayoutParamsCompat.getMarginStart(params));
MarginLayoutParamsCompat.setMarginEnd(mPreservedParams,
MarginLayoutParamsCompat.getMarginEnd(params));
if (leftMarginPercent >= 0) {
params.leftMargin = (int) (widthHint * leftMarginPercent);
}
if (topMarginPercent >= 0) {
params.topMargin = (int) (heightHint * topMarginPercent);
}
if (rightMarginPercent >= 0) {
params.rightMargin = (int) (widthHint * rightMarginPercent);
}
if (bottomMarginPercent >= 0) {
params.bottomMargin = (int) (heightHint * bottomMarginPercent);
}
boolean shouldResolveLayoutDirection = false;
if (startMarginPercent >= 0) {
MarginLayoutParamsCompat.setMarginStart(params,
(int) (widthHint * startMarginPercent));
shouldResolveLayoutDirection = true;
}
if (endMarginPercent >= 0) {
MarginLayoutParamsCompat.setMarginEnd(params,
(int) (widthHint * endMarginPercent));
shouldResolveLayoutDirection = true;
}
if (shouldResolveLayoutDirection && (view != null)) {
// Force the resolve pass so that start / end margins are propagated to the
// matching left / right fields
MarginLayoutParamsCompat.resolveLayoutDirection(params,
ViewCompat.getLayoutDirection(view));
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "after fillMarginLayoutParams: (" + params.width + ", " + params.height
+ ")");
}
}
示例15: applyXmlAttributes
import android.support.v4.view.MarginLayoutParamsCompat; //导入方法依赖的package包/类
private void applyXmlAttributes(AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
final TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.FloatingSearchView, defStyleAttr, defStyleRes);
// Search bar width
View suggestionsContainer = findViewById(R.id.fsv_suggestions_container);
int searchBarWidth = a.getDimensionPixelSize(R.styleable.FloatingSearchView_fsv_searchBarWidth,
mSearchContainer.getLayoutParams().width);
mSearchContainer.getLayoutParams().width = searchBarWidth;
suggestionsContainer.getLayoutParams().width = searchBarWidth;
// Divider
mDivider.setBackgroundDrawable(a.getDrawable(R.styleable.FloatingSearchView_android_divider));
int dividerHeight = a.getDimensionPixelSize(R.styleable.FloatingSearchView_android_dividerHeight, -1);
MarginLayoutParams dividerLP = (MarginLayoutParams) mDivider.getLayoutParams();
if (mDivider.getBackground() != null && dividerHeight != -1)
dividerLP.height = dividerHeight;
float maxShadowSize = mSearchBackground.getMaxShadowSize();
float cornerRadius = mSearchBackground.getCornerRadius();
int horizontalPadding = (int) (RoundRectDrawableWithShadow.calculateHorizontalPadding(
maxShadowSize, cornerRadius, false) + .5f);
dividerLP.setMargins(horizontalPadding, dividerLP.topMargin, horizontalPadding, dividerLP.bottomMargin);
mDivider.setLayoutParams(dividerLP);
// Content inset
MarginLayoutParams searchParams = (MarginLayoutParams) mSearchInput.getLayoutParams();
int contentInsetStart = a.getDimensionPixelSize(R.styleable.FloatingSearchView_contentInsetStart,
MarginLayoutParamsCompat.getMarginStart(searchParams));
int contentInsetEnd = a.getDimensionPixelSize(R.styleable.FloatingSearchView_contentInsetEnd,
MarginLayoutParamsCompat.getMarginEnd(searchParams));
MarginLayoutParamsCompat.setMarginStart(searchParams, contentInsetStart);
MarginLayoutParamsCompat.setMarginEnd(searchParams, contentInsetEnd);
// anything else
setLogo(a.getDrawable(R.styleable.FloatingSearchView_logo));
setContentBackgroundColor(a.getColor(R.styleable.FloatingSearchView_fsv_contentBackgroundColor, DEFAULT_CONTENT_COLOR));
setRadius(a.getDimensionPixelSize(R.styleable.FloatingSearchView_fsv_cornerRadius, ViewUtils.dpToPx(DEFAULT_RADIUS)));
inflateMenu(a.getResourceId(R.styleable.FloatingSearchView_fsv_menu, 0));
setPopupTheme(a.getResourceId(R.styleable.FloatingSearchView_popupTheme, 0));
setHint(a.getString(R.styleable.FloatingSearchView_android_hint));
setIcon(a.getDrawable(R.styleable.FloatingSearchView_fsv_icon));
a.recycle();
}