本文整理匯總了Java中io.plaidapp.util.ViewUtils類的典型用法代碼示例。如果您正苦於以下問題:Java ViewUtils類的具體用法?Java ViewUtils怎麽用?Java ViewUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ViewUtils類屬於io.plaidapp.util包,在下文中一共展示了ViewUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hideSaveConfimation
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@OnClick(R.id.results_scrim)
protected void hideSaveConfimation() {
if (confirmSaveContainer.getVisibility() == View.VISIBLE) {
// contract the bubble & hide the scrim
AnimatorSet hideConfirmation = new AnimatorSet();
hideConfirmation.playTogether(
ViewAnimationUtils.createCircularReveal(confirmSaveContainer,
confirmSaveContainer.getWidth() / 2,
confirmSaveContainer.getHeight() / 2,
confirmSaveContainer.getWidth() / 2,
fab.getWidth() / 2),
ObjectAnimator.ofArgb(resultsScrim,
ViewUtils.BACKGROUND_COLOR,
Color.TRANSPARENT));
hideConfirmation.setDuration(150L);
hideConfirmation.setInterpolator(AnimUtils.getFastOutSlowInInterpolator
(SearchActivity.this));
hideConfirmation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
confirmSaveContainer.setVisibility(View.GONE);
resultsScrim.setVisibility(View.GONE);
fab.setVisibility(results.getVisibility());
}
});
hideConfirmation.start();
}
}
示例2: onSizeChanged
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
final float expandedTitleTextSize = Math.max(minTextSize,
ViewUtils.getSingleLineTextSize(getText().toString(), getPaint(),
w - getPaddingStart() - getPaddingEnd(),
minTextSize,
maxTextSize, 0.5f, getResources().getDisplayMetrics()));
setTextSize(TypedValue.COMPLEX_UNIT_PX, expandedTitleTextSize);
}
示例3: calculateTextPosition
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
private void calculateTextPosition() {
float targetWidth = getWidth() / PHI;
textSize = ViewUtils.getSingleLineTextSize(text, textPaint, targetWidth, 0f, maxTextSize,
0.5f, getResources().getDisplayMetrics());
textPaint.setTextSize(textSize);
// measuring text is fun :] see: https://chris.banes.me/2014/03/27/measuring-text/
textX = (getWidth() - textPaint.measureText(text)) / 2;
Rect textBounds = new Rect();
textPaint.getTextBounds(text, 0, text.length(), textBounds);
float textHeight = textBounds.height();
textY = (getHeight() + textHeight) / 2;
}
示例4: onAppear
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@Override
public Animator onAppear(ViewGroup sceneRoot, View view,
TransitionValues startValues, TransitionValues endValues) {
if (view == null || view.getBackground() == null) return null;
Drawable background = view.getBackground();
background.setAlpha(0);
return ObjectAnimator.ofInt(background, ViewUtils.DRAWABLE_ALPHA, 0, 255);
}
示例5: calculateTextPosition
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
private void calculateTextPosition() {
float targetWidth = getWidth() / PHI;
float textSize = ViewUtils.getSingleLineTextSize(
text, textPaint, targetWidth, 0f, maxTextSize, 0.5f, getResources().getDisplayMetrics());
textPaint.setTextSize(textSize);
// measuring text is fun :] see: https://chris.banes.me/2014/03/27/measuring-text/
textX = (getWidth() - textPaint.measureText(text)) / 2;
Rect textBounds = new Rect();
textPaint.getTextBounds(text, 0, text.length(), textBounds);
float textHeight = textBounds.height();
textY = (getHeight() + textHeight) / 2;
}
示例6: doFabExpand
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
private void doFabExpand() {
// translate the chrome placeholder ui so that it is centered on the FAB
int fabCenterX = (fab.getLeft() + fab.getRight()) / 2;
int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop();
int translateX = fabCenterX - (fabExpand.getWidth() / 2);
int translateY = fabCenterY - (fabExpand.getHeight() / 2);
fabExpand.setTranslationX(translateX);
fabExpand.setTranslationY(translateY);
// then reveal the placeholder ui, starting from the center & same dimens as fab
fabExpand.setVisibility(View.VISIBLE);
Animator reveal = ViewAnimationUtils.createCircularReveal(
fabExpand,
fabExpand.getWidth() / 2,
fabExpand.getHeight() / 2,
fab.getWidth() / 2,
(int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2))
.setDuration(fabExpandDuration);
// translate the placeholder ui back into position along an arc
GravityArcMotion arcMotion = new GravityArcMotion();
arcMotion.setMinimumVerticalAngle(70f);
Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0);
Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View
.TRANSLATION_Y, motionPath)
.setDuration(fabExpandDuration);
// animate from the FAB colour to the placeholder background color
Animator background = ObjectAnimator.ofArgb(fabExpand,
ViewUtils.BACKGROUND_COLOR,
ContextCompat.getColor(this, R.color.designer_news),
ContextCompat.getColor(this, R.color.background_light))
.setDuration(fabExpandDuration);
// fade out the fab (rapidly)
Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f)
.setDuration(60);
// play 'em all together with the material interpolator
AnimatorSet show = new AnimatorSet();
show.setInterpolator(getFastOutSlowInInterpolator(DesignerNewsStory.this));
show.playTogether(reveal, background, position, fadeOutFab);
show.start();
}
示例7: save
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@OnClick(R.id.fab)
protected void save() {
// show the save confirmation bubble
fab.setVisibility(View.INVISIBLE);
confirmSaveContainer.setVisibility(View.VISIBLE);
resultsScrim.setVisibility(View.VISIBLE);
// expand it once it's been measured and show a scrim over the search results
confirmSaveContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver
.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
// expand the confirmation
confirmSaveContainer.getViewTreeObserver().removeOnPreDrawListener(this);
Animator reveal = ViewAnimationUtils.createCircularReveal(confirmSaveContainer,
confirmSaveContainer.getWidth() / 2,
confirmSaveContainer.getHeight() / 2,
fab.getWidth() / 2,
confirmSaveContainer.getWidth() / 2);
reveal.setDuration(250L);
reveal.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(SearchActivity.this));
reveal.start();
// show the scrim
int centerX = (fab.getLeft() + fab.getRight()) / 2;
int centerY = (fab.getTop() + fab.getBottom()) / 2;
Animator revealScrim = ViewAnimationUtils.createCircularReveal(
resultsScrim,
centerX,
centerY,
0,
(float) Math.hypot(centerX, centerY));
revealScrim.setDuration(400L);
revealScrim.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(SearchActivity
.this));
revealScrim.start();
ObjectAnimator fadeInScrim = ObjectAnimator.ofArgb(resultsScrim,
ViewUtils.BACKGROUND_COLOR,
Color.TRANSPARENT,
ContextCompat.getColor(SearchActivity.this, R.color.scrim));
fadeInScrim.setDuration(800L);
fadeInScrim.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(SearchActivity
.this));
fadeInScrim.start();
// ease in the checkboxes
saveDribbble.setAlpha(0.6f);
saveDribbble.setTranslationY(saveDribbble.getHeight() * 0.4f);
saveDribbble.animate()
.alpha(1f)
.translationY(0f)
.setDuration(200L)
.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(SearchActivity
.this));
saveDesignerNews.setAlpha(0.6f);
saveDesignerNews.setTranslationY(saveDesignerNews.getHeight() * 0.5f);
saveDesignerNews.animate()
.alpha(1f)
.translationY(0f)
.setDuration(200L)
.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(SearchActivity
.this));
return false;
}
});
}
示例8: onCreate
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dribbble_player);
ButterKnife.bind(this);
circleTransform = new CircleTransform(this);
chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);
final Intent intent = getIntent();
if (intent.hasExtra(EXTRA_PLAYER)) {
player = intent.getParcelableExtra(EXTRA_PLAYER);
bindPlayer();
} else if (intent.hasExtra(EXTRA_PLAYER_NAME)) {
String name = intent.getStringExtra(EXTRA_PLAYER_NAME);
playerName.setText(name);
if (intent.hasExtra(EXTRA_PLAYER_ID)) {
long userId = intent.getLongExtra(EXTRA_PLAYER_ID, 0l);
loadPlayer(userId);
} else if (intent.hasExtra(EXTRA_PLAYER_USERNAME)) {
String username = intent.getStringExtra(EXTRA_PLAYER_USERNAME);
loadPlayer(username);
}
} else if (intent.getData() != null) {
// todo support url intents
}
// setup immersive mode i.e. draw behind the system chrome & adjust insets
draggableFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
draggableFrame.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
((ViewGroup.MarginLayoutParams) draggableFrame.getLayoutParams()).rightMargin
+= insets.getSystemWindowInsetRight(); // landscape
((ViewGroup.MarginLayoutParams) avatar.getLayoutParams()).topMargin
+= insets.getSystemWindowInsetTop();
ViewUtils.setPaddingTop(playerDescription, insets.getSystemWindowInsetTop());
ViewUtils.setPaddingBottom(shots, insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
draggableFrame.setOnApplyWindowInsetsListener(null);
return insets;
}
});
}
示例9: recalculate
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
private void recalculate(int width) {
// reset stateful objects that might change over measure passes
paint.setTextSize(collapsedTextSize);
displayText = new SpannableStringBuilder(title);
// Calculate line height; ensure it' a multiple of 4dp to sit on the grid
final float fourDip = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
getResources().getDisplayMetrics());
Paint.FontMetricsInt fm = paint.getFontMetricsInt();
int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading;
final int baselineAlignedLineHeight =
(int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip));
final int lineSpacingAdd = baselineAlignedLineHeight - fontHeight;
// now create the layout with our desired insets & line height
createLayout(width, lineSpacingAdd);
// adjust the displayText top inset to vertically center text with the toolbar
collapsedHeight = (int) Math.max(ViewUtils.getActionBarSize(getContext()),
(fourDip + baselineAlignedLineHeight + fourDip));
titleInsetTop = (collapsedHeight - baselineAlignedLineHeight) / 2f;
if (lineCount == 1) { // single line mode
layout = null;
collapsingText = new CollapsingTextHelper(this);
collapsingText.setText(title);
collapsingText.setCollapsedBounds(titleInsetStart,
0,
width - titleInsetEnd,
(int) collapsedHeight);
collapsingText.setExpandedBounds(titleInsetStart,
(int) titleInsetTop,
width - titleInsetEnd,
getMinimumHeight() - titleInsetBottom);
collapsingText.setCollapsedTextColor(paint.getColor());
collapsingText.setExpandedTextColor(paint.getColor());
collapsingText.setCollapsedTextSize(collapsedTextSize);
int expandedTitleTextSize = (int) Math.max(collapsedTextSize,
ViewUtils.getSingleLineTextSize(displayText.toString(), paint,
width - titleInsetStart - titleInsetEnd,
collapsedTextSize,
maxExpandedTextSize, 0.5f, getResources().getDisplayMetrics()));
collapsingText.setExpandedTextSize(expandedTitleTextSize);
collapsingText.setExpandedTextGravity(GravityCompat.START | Gravity.BOTTOM);
collapsingText.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL);
collapsingText.setTypeface(paint.getTypeface());
fm = paint.getFontMetricsInt();
fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading;
textTop = getHeight() - titleInsetBottom - fontHeight;
scrollRange = getMinimumHeight() - (int) collapsedHeight;
} else { // multi-line mode
// bottom align the text
textTop = getDesiredHeight() - titleInsetBottom - layout.getHeight();
// pre-calculate at what scroll offsets lines should disappear
scrollRange = (int) (textTop - titleInsetTop);
final int fadeDistance = lineSpacingAdd + fm.descent; // line bottom to baseline
lines = new Line[lineCount];
for (int i = 1; i < lineCount; i++) {
int lineBottomScrollOffset =
scrollRange + ((lineCount - i - 1) * baselineAlignedLineHeight);
lines[i] = new Line(
layout.getLineStart(i),
layout.getLineEnd(i),
new ForegroundColorSpan(paint.getColor()),
lineBottomScrollOffset,
lineBottomScrollOffset + fadeDistance);
}
}
calculatedWithWidth = width;
}
示例10: SystemChromeFader
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
public SystemChromeFader(Activity activity) {
this.activity = activity;
statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor());
navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor());
fadeNavBar = ViewUtils.isNavBarOnBottom(activity);
}
示例11: CircularImageView
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
public CircularImageView(Context context, AttributeSet attrs) {
super(context, attrs);
setOutlineProvider(ViewUtils.CIRCULAR_OUTLINE);
setClipToOutline(true);
}
示例12: onGenerated
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@Override
public void onGenerated(Palette palette) {
((BadgedFourThreeImageView) getView()).setForeground(
ViewUtils.createRipple(palette, 0.25f, 0.5f,
ContextCompat.getColor(getView().getContext(), R.color.mid_grey), true));
}
示例13: onDisappear
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view,
TransitionValues startValues, TransitionValues endValues) {
if (view == null || view.getBackground() == null) return null;
return ObjectAnimator.ofInt(view.getBackground(), ViewUtils.DRAWABLE_ALPHA, 0);
}
示例14: onCreate
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dribbble_player);
ButterKnife.bind(this);
circleTransform = new CircleTransform(this);
chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);
final Intent intent = getIntent();
if (intent.hasExtra(EXTRA_PLAYER)) {
player = intent.getParcelableExtra(EXTRA_PLAYER);
bindPlayer();
} else if (intent.hasExtra(EXTRA_PLAYER_NAME)) {
String name = intent.getStringExtra(EXTRA_PLAYER_NAME);
playerName.setText(name);
if (intent.hasExtra(EXTRA_PLAYER_ID)) {
long userId = intent.getLongExtra(EXTRA_PLAYER_ID, 0L);
loadPlayer(userId);
} else if (intent.hasExtra(EXTRA_PLAYER_USERNAME)) {
String username = intent.getStringExtra(EXTRA_PLAYER_USERNAME);
loadPlayer(username);
}
} else if (intent.getData() != null) {
// todo support url intents
}
// setup immersive mode i.e. draw behind the system chrome & adjust insets
draggableFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
draggableFrame.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
final ViewGroup.MarginLayoutParams lpFrame = (ViewGroup.MarginLayoutParams)
draggableFrame.getLayoutParams();
lpFrame.leftMargin += insets.getSystemWindowInsetLeft(); // landscape
lpFrame.rightMargin += insets.getSystemWindowInsetRight(); // landscape
((ViewGroup.MarginLayoutParams) avatar.getLayoutParams()).topMargin
+= insets.getSystemWindowInsetTop();
ViewUtils.setPaddingTop(container, insets.getSystemWindowInsetTop());
ViewUtils.setPaddingBottom(shots, insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
draggableFrame.setOnApplyWindowInsetsListener(null);
return insets;
}
});
setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
}
示例15: recalculate
import io.plaidapp.util.ViewUtils; //導入依賴的package包/類
private void recalculate(int width) {
// reset stateful objects that might change over measure passes
paint.setTextSize(collapsedTextSize);
displayText = new SpannableStringBuilder(title);
// Calculate line height; ensure it' a multiple of 4dp to sit on the grid
final float fourDip = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
getResources().getDisplayMetrics());
Paint.FontMetricsInt fm = paint.getFontMetricsInt();
int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading;
final int baselineAlignedLineHeight =
(int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip));
lineSpacingAdd = Math.max(0, baselineAlignedLineHeight - fontHeight);
// now create the layout with our desired insets & line height
createLayout(width, lineSpacingAdd);
// adjust the title top inset to vertically center text with the toolbar
collapsedHeight = (int) Math.max(ViewUtils.getActionBarSize(getContext()),
(fourDip + baselineAlignedLineHeight + fourDip));
titleInsetTop = (collapsedHeight - baselineAlignedLineHeight) / 2f;
if (lineCount == 1) { // single line mode
layout = null;
collapsingText = new CollapsingTextHelper(this);
collapsingText.setText(title);
collapsingText.setCollapsedBounds(titleInsetStart,
0,
width - titleInsetEnd,
(int) collapsedHeight);
collapsingText.setExpandedBounds(titleInsetStart,
(int) titleInsetTop,
width - titleInsetEnd,
getMinimumHeight() - titleInsetBottom);
collapsingText.setCollapsedTextColor(paint.getColor());
collapsingText.setExpandedTextColor(paint.getColor());
collapsingText.setCollapsedTextSize(collapsedTextSize);
int expandedTitleTextSize = (int) Math.max(collapsedTextSize,
ViewUtils.getSingleLineTextSize(displayText.toString(), paint,
width - titleInsetStart - titleInsetEnd,
collapsedTextSize,
maxExpandedTextSize, 0.5f, getResources().getDisplayMetrics()));
collapsingText.setExpandedTextSize(expandedTitleTextSize);
collapsingText.setExpandedTextGravity(GravityCompat.START | Gravity.BOTTOM);
collapsingText.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL);
collapsingText.setTypeface(paint.getTypeface());
textTop = getHeight() - titleInsetBottom - fontHeight;
scrollRange = getMinimumHeight() - (int) collapsedHeight;
} else { // multi-line mode
// bottom align the text
textTop = getDesiredHeight() - titleInsetBottom - layout.getHeight();
// pre-calculate at what scroll offsets lines should disappear
scrollRange = (int) (textTop - titleInsetTop);
final int fadeDistance = layout.getLineBottom(0) - layout.getLineBaseline(0);
lines = new Line[lineCount];
for (int i = 1; i < lineCount; i++) {
int lineBottomScrollOffset =
scrollRange + ((lineCount - i - 1) * baselineAlignedLineHeight);
lines[i] = new Line(
layout.getLineStart(i),
layout.getLineEnd(i),
new TextColorSpan(paint.getColor()),
lineBottomScrollOffset,
lineBottomScrollOffset + fadeDistance);
}
}
calculatedWithWidth = width;
}