下面列出了android.widget.LinearLayout#setTranslationY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void initOtherViews() {
layoutAbout = (LinearLayout) findViewById(R.id.layout_about);
layoutAbout.setVisibility(View.VISIBLE);
layoutAbout.setAlpha(0);
layoutAbout.setTranslationY(-30);
layoutAbout.animate()
.setDuration(300)
.alpha(1)
.translationY(0);
ivAdd = (ImageView) findViewById(R.id.iv_add);
ivAdd.setVisibility(View.VISIBLE);
ivAdd.setScaleX(0);
ivAdd.setScaleY(0);
ivAdd.animate()
.setDuration(200)
.scaleX(1)
.scaleY(1);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onDependentViewChanged(@NonNull final CoordinatorLayout parent, @NonNull final LinearLayout child, @NonNull final View dependency) {
final Boolean apiCompatible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
if (apiCompatible) {
final Float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
}
return apiCompatible;
}
@Override protected void onAttachedToWindow() {
super.onAttachedToWindow();
LinearLayout progressbarLayout = (LinearLayout) findViewById(R.id.progressbar_layout);
progressbarLayout.setTranslationY(-mLayoutHeight);
progressbarLayout.setVisibility(VISIBLE);
ObjectAnimator animator =
ObjectAnimator.ofFloat(progressbarLayout, "translationY", -mLayoutHeight, 0);
animator.setInterpolator(new DecelerateInterpolator());
animator.setDuration(500);
animator.start();
}
private void showNotificationContent() {
if (mContentShowing) {
// Content is already showing.
return;
}
mContentShowing = true;
StatusBarNotification selectedNotification =
(StatusBarNotification) mNotificationPeek.getNotificationView().getTag();
View contentView = PeekLayoutFactory
.createPeekLayout(getContext(), PeekLayoutFactory.LAYOUT_TYPE_CONTENT,
selectedNotification);
contentView.setId(R.id.notification_content);
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.ABOVE, R.id.notification_layout);
contentView.setLayoutParams(params);
// Animations.
LinearLayout contentTextLayout =
(LinearLayout) contentView.findViewById(R.id.content_layout);
contentTextLayout.setTranslationY(50);
contentView.setAlpha(0);
((ViewGroup)getParent()).addView(contentView);
contentView.animate().alpha(1f).setInterpolator(new DecelerateInterpolator()).start();
contentTextLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator())
.start();
// Send broadcast to NotificationPeekActivity and let it hide the other components
// when the content is displayed.
Intent intent =
new Intent(NotificationPeekActivity.NotificationPeekReceiver.ACTION_SHOW_CONTENT);
getContext().sendBroadcast(intent);
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, LinearLayout child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, LinearLayout child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, LinearLayout child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}
private void hideSearchPad() {
LinearLayout rltSearch = (LinearLayout) findViewById(R.id.lltSearch);
rltSearch.setTranslationY(size.y);
}