我有一个内部有4个ImeButtons的RelativeLayout。 我想要一个用于alpha淡入到相对布局的动画,同时,ImageViews从底部到屏幕显示到它们的位置。
这可能吗?
现在将相同的动画(翻译)应用于所有视图,我希望你敢于使用带有翻译动画的ImageButtons,并且使用alpha动画显示TableLayout
public class Panel extends TableLayout {
private Animation showAnimation;
private ImageButton bt;
private ImageButton bt2;
private ImageButton bt3;
private ImageButton bt4;
public Panel(Context context, AttributeSet attrs) {
super(context, attrs);
inflateViewWith(context);
loadAnimationResource();
setVisibility(View.INVISIBLE);
}
private void mapGui() {
//findviewsbyid
}
public void setNewViewAndAnimate(int newVisibility) {
if (newVisibility == View.VISIBLE) {
startAnimation(showAnimation);
animateIcons();
} else {
setVisibility(newVisibility);
}
}
private void animateIcons() {
animateIcon(bt);
animateIcon(bt1);
animateIcon(bt2);
animateIcon(bt3);
}
private void loadAnimationResource() {
showAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.view_changes_alpha_show);
}
private void animateIcon(View view) {
Animation translateAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.panel_icons_show);
translateAnimation.setFillAfter(true);
translateAnimation.setInterpolator(new DecelerateInterpolator());
view.startAnimation(translateAnimation);
}
private void inflateViewWith(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.pane, this, true);
}
}
panel_icons_show.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:fillAfter="true"
android:fromXDelta="100%p"
android:fromYDelta="-100%p"
android:toXDelta="0"
android:toYDelta="0"/>
其他视图包含此自定义视图,按标签膨胀,我从公共方法和动画图标设置当前可见性。但这会将变换动画应用于所有视图和图标..
答案 0 :(得分:0)
我能从我们的谈话中看到和知道什么......
public void setNewViewAndAnimate(int newVisibility) {
if (newVisibility == View.VISIBLE) {
startAnimation(showAnimation);
animateIcons();
} else {
setVisibility(newVisibility);
}
}
您没有设置应淡入哪个视图,只能调用
startAnimation(showAnimation);
并且在Show Animation中你只加载动画,但你没有声明哪个View应该获得动画......也许这就是Point。只是一个猜测。
给我更新