下面列出了android.view.View#getPaddingRight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onBindView(View view) {
super.onBindView(view);
if (mDrawDivider) {
int left = view.getPaddingLeft();
int right = view.getPaddingRight();
int top = view.getPaddingTop();
int bottom = view.getPaddingBottom();
view.setBackground(DividerDrawable.create(getContext()));
view.setPadding(left, top, right, bottom);
}
SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.switch_widget);
// On BLU Life Play devices SwitchPreference.setWidgetLayoutResource() does nothing. As a
// result, the user will see a non-material Switch and switchView will be null, hence the
// null check below. http://crbug.com/451447
if (switchView != null) {
switchView.setChecked(isChecked());
}
TextView title = (TextView) view.findViewById(android.R.id.title);
title.setSingleLine(false);
if (!mDontUseSummaryAsTitle && TextUtils.isEmpty(getTitle())) {
TextView summary = (TextView) view.findViewById(android.R.id.summary);
title.setText(summary.getText());
title.setVisibility(View.VISIBLE);
summary.setVisibility(View.GONE);
}
if (mManagedPrefDelegate != null) mManagedPrefDelegate.onBindViewToPreference(this, view);
}
@Override
protected void execute(View view, int val)
{
int l = val;
int t = view.getPaddingTop();
int r = view.getPaddingRight();
int b = view.getPaddingBottom();
view.setPadding(l, t, r, b);
}
public static void autoPadding(View view) {
int l = view.getPaddingLeft();
int t = view.getPaddingTop();
int r = view.getPaddingRight();
int b = view.getPaddingBottom();
l = getDisplayWidthValue(l);
t = getDisplayHeightValue(t);
r = getDisplayWidthValue(r);
b = getDisplayHeightValue(b);
view.setPadding(l, t, r, b);
}
public static void resetViewBottomPadding(@Nullable View view, boolean scroll) {
if (view == null) return;
Context context = ContextHelper.getBaseContext(view);
int orientation = context.getResources().getConfiguration().orientation;
int left = view.getPaddingLeft();
int right = view.getPaddingRight();
int bottom = view.getPaddingTop();
int top = view.getPaddingTop();
int navBar = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
boolean tabletMode = context.getResources().getBoolean(R.bool.android_helpers_tablet_mode);
if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) {
navBar = getNavigationBarHeight(context);
}
if (!scroll) {
navBar += getStatusBarHeight(context);
}
}
if (!scroll) {
navBar += getToolbarHeight(context);
}
view.setPadding(left, top, right, (bottom + navBar));
}
public static void autoPadding(View view)
{
Object tag = view.getTag(R.id.id_tag_autolayout_padding);
if (tag != null) return;
view.setTag(R.id.id_tag_autolayout_padding, "Just Identify");
int l = view.getPaddingLeft();
int t = view.getPaddingTop();
int r = view.getPaddingRight();
int b = view.getPaddingBottom();
l = getPercentWidthSize(l);
t = getPercentHeightSize(t);
r = getPercentWidthSize(r);
b = getPercentHeightSize(b);
view.setPadding(l, t, r, b);
}
/**
* Sets the background of a view to the given 9-patch resource and restores its padding. This
* works around a bug in Android where the padding is lost when a 9-patch resource is applied
* programmatically.
*/
public static void setNinePatchBackgroundResource(View view, @DrawableRes int resource) {
int left = view.getPaddingLeft();
int top = view.getPaddingTop();
int right = view.getPaddingRight();
int bottom = view.getPaddingBottom();
view.setBackgroundResource(resource);
view.setPadding(left, top, right, bottom);
}
@Override
public void prepare(View target) {
float x = target.getWidth() - target.getPaddingRight();
float y = target.getHeight() - target.getPaddingBottom();
getAnimatorAgent().playTogether(
ObjectAnimator.ofFloat(target, "alpha", 1, 0),
ObjectAnimator.ofFloat(target,"rotation",0,-90),
ObjectAnimator.ofFloat(target,"pivotX",x,x),
ObjectAnimator.ofFloat(target,"pivotY",y,y)
);
}
public static void measureDynamicHeight(View view) {
int width = view.getWidth();
if (width <= 0) {
View parent = (View) view.getParent();
width = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight();
}
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
view.measure(widthMeasureSpec, heightMeasureSpec);
}
@Override
public void prepare(View target) {
float x = target.getWidth() - target.getPaddingRight();
float y = target.getHeight() - target.getPaddingBottom();
getAnimatorAgent().playTogether(
ObjectAnimator.ofFloat(target, "alpha", 1, 0),
ObjectAnimator.ofFloat(target,"rotation",0,-90),
ObjectAnimator.ofFloat(target,"pivotX",x,x),
ObjectAnimator.ofFloat(target,"pivotY",y,y)
);
}
@Override
protected void execute(View view, int val)
{
int l = view.getPaddingLeft();
int t = val;
int r = view.getPaddingRight();
int b = view.getPaddingBottom();
view.setPadding(l, t, r, b);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
if (mDrawDivider) {
int left = view.getPaddingLeft();
int right = view.getPaddingRight();
int top = view.getPaddingTop();
int bottom = view.getPaddingBottom();
view.setBackground(DividerDrawable.create(getContext()));
view.setPadding(left, top, right, bottom);
}
SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.switch_widget);
// On BLU Life Play devices SwitchPreference.setWidgetLayoutResource() does nothing. As a
// result, the user will see a non-material Switch and switchView will be null, hence the
// null check below. http://crbug.com/451447
if (switchView != null) {
switchView.setChecked(isChecked());
}
TextView title = (TextView) view.findViewById(android.R.id.title);
title.setSingleLine(false);
if (!mDontUseSummaryAsTitle && TextUtils.isEmpty(getTitle())) {
TextView summary = (TextView) view.findViewById(android.R.id.summary);
title.setText(summary.getText());
title.setVisibility(View.VISIBLE);
summary.setVisibility(View.GONE);
}
if (mManagedPrefDelegate != null) mManagedPrefDelegate.onBindViewToPreference(this, view);
}
@Override
public void prepare(View target) {
float x = target.getWidth() - target.getPaddingRight();
float y = target.getHeight() - target.getPaddingBottom();
getAnimatorAgent().playTogether(
ObjectAnimator.ofFloat(target, "rotation", -90, 0),
ObjectAnimator.ofFloat(target, "alpha", 0, 1),
ObjectAnimator.ofFloat(target, "pivotX", x, x),
ObjectAnimator.ofFloat(target, "pivotY", y, y)
);
}
@Override
public void prepare(View target) {
float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight())/2
+ target.getPaddingLeft();
float y = target.getHeight() - target.getPaddingBottom();
getAnimatorAgent().playTogether(
ObjectAnimator.ofFloat(target, "rotation", 12,-12,3,-3,0),
ObjectAnimator.ofFloat(target, "pivotX", x, x,x,x,x),
ObjectAnimator.ofFloat(target, "pivotY", y, y,y,y,y)
);
}
public AnimationBuilder standUp() {
for (View view : views) {
float x = (view.getWidth() - view.getPaddingLeft() - view.getPaddingRight()) / 2
+ view.getPaddingLeft();
float y = view.getHeight() - view.getPaddingBottom();
pivotX(x, x, x, x, x);
pivotY(y, y, y, y, y);
rotationX(55, -30, 15, -15, 0);
}
return this;
}
@Override
protected void execute(View view, int val)
{
int l = val;
int t = view.getPaddingTop();
int r = view.getPaddingRight();
int b = view.getPaddingBottom();
view.setPadding(l, t, r, b);
}
@Override
public Float get(View object) {
return (float) object.getPaddingRight();
}
public static int getPaddingEnd(View view) {
return LocaleController.isRTL ? view.getPaddingLeft() : view.getPaddingRight();
}
public int getPaddingEnd(View view) {
return view.getPaddingRight();
}
@Override
public void onMeasure(View v, int viewWidth, int viewHeight, int allContentWidth, int allContentHeight) {
float retTopPaddingSize = initTimeTextBaselineAndTimeBgTopPadding(viewHeight, v.getPaddingTop(), v.getPaddingBottom(), allContentHeight);
mLeftPaddingSize = v.getPaddingLeft() == v.getPaddingRight() ? (viewWidth - allContentWidth) / 2 : v.getPaddingLeft();
initTimeBgRect(retTopPaddingSize);
}
public static int getPaddingEnd(View view) {
return LocaleController.isRTL ? view.getPaddingLeft() : view.getPaddingRight();
}