use of android.view.ViewGroup.MarginLayoutParams in project UltimateAndroid by cymcsg.
the class BaseLayoutManager method generateLayoutParams.
@Override
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
final LayoutParams lanedLp = new LayoutParams((MarginLayoutParams) lp);
if (isVertical()) {
lanedLp.width = LayoutParams.MATCH_PARENT;
lanedLp.height = lp.height;
} else {
lanedLp.width = lp.width;
lanedLp.height = LayoutParams.MATCH_PARENT;
}
return lanedLp;
}
use of android.view.ViewGroup.MarginLayoutParams in project UltimateAndroid by cymcsg.
the class SpannableGridLayoutManager method generateLayoutParams.
@Override
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
final LayoutParams spannableLp = new LayoutParams((MarginLayoutParams) lp);
spannableLp.width = LayoutParams.MATCH_PARENT;
spannableLp.height = LayoutParams.MATCH_PARENT;
if (lp instanceof LayoutParams) {
final LayoutParams other = (LayoutParams) lp;
if (isVertical()) {
spannableLp.colSpan = Math.max(1, Math.min(other.colSpan, getLaneCount()));
spannableLp.rowSpan = Math.max(1, other.rowSpan);
} else {
spannableLp.colSpan = Math.max(1, other.colSpan);
spannableLp.rowSpan = Math.max(1, Math.min(other.rowSpan, getLaneCount()));
}
}
return spannableLp;
}
use of android.view.ViewGroup.MarginLayoutParams in project SmartAndroidSource by jaychou2012.
the class AbstractAQuery method margin.
/**
* Set the margin of a view. Notes all parameters are in DIP, not in pixel.
*
* @param leftDip the left dip
* @param topDip the top dip
* @param rightDip the right dip
* @param bottomDip the bottom dip
* @return self
*/
public T margin(float leftDip, float topDip, float rightDip, float bottomDip) {
if (view != null) {
LayoutParams lp = view.getLayoutParams();
if (lp instanceof MarginLayoutParams) {
Context context = getContext();
int left = AQUtility.dip2pixel(context, leftDip);
int top = AQUtility.dip2pixel(context, topDip);
int right = AQUtility.dip2pixel(context, rightDip);
int bottom = AQUtility.dip2pixel(context, bottomDip);
((MarginLayoutParams) lp).setMargins(left, top, right, bottom);
view.setLayoutParams(lp);
}
}
return self();
}
use of android.view.ViewGroup.MarginLayoutParams in project android-demos by novoda.
the class LeftNavBar method setTopMargin.
private void setTopMargin(View view, int margin) {
MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams();
params.topMargin = margin;
view.setLayoutParams(params);
}
use of android.view.ViewGroup.MarginLayoutParams in project platform_frameworks_base by android.
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