java如何使ImageView部分可见并在之后完全淡入?
我目前正在制作一个应用程序,我希望应用程序的部分徽标出现在屏幕的中心,转换到顶部,然后显示整个徽标。我目前有一个应用程序显示整个标志,并根据需要进行翻译,但我不知道如何隐藏大部分标志,并使其显示后。我的徽标由左侧的图标和右侧的文本组成。一旦标志达到顶部,我希望名称出现顺利,同时推动图标的左侧,因为它去。是否有一种方法可以使用我现有的代码来实现这一点
logo_动画。xml:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:fillAfter="true">
<alpha
安卓:duration="800"
安卓:fromAlpha="0.0"
安卓:interpolator="@安卓:anim/accelerate_interpolator"
安卓:toAlpha="1.0" />
<translate
安卓:duration="800"
安卓:fillAfter="true"
安卓:fromYDelta="0%p"
安卓:startOffset="2000"
安卓:toYDelta="-30%p" />
</set>
梅因。xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:id="@+id/main"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:paddingLeft="15dp"
安卓:paddingStart="15dp"
安卓:paddingRight="15dp"
安卓:paddingEnd="15dp"
安卓:background="@color/colorPrimary"
tools:context=".Main">
<ImageView
安卓:id="@+id/mainLogo"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_centerInParent="true"
安卓:contentDescription="@string/logo"
安卓:src="@mipmap/ic_launcher" />
</RelativeLayout>
梅因。爪哇:
import 安卓.support.v7.app.AppCompatActivity;
import 安卓.os.Bundle;
import 安卓.view.animation.Animation;
import 安卓.view.animation.AnimationUtils;
import 安卓.view.animation.Animation.AnimationListener;
import 安卓.widget.ImageView;
public class Main extends AppCompatActivity implements AnimationListener {
ImageView mainLogo;
Animation mainLogoAnimation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
searchLogo = (ImageView) findViewById(R.id.searchLogo);
mainLogoAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.logo_animation);
mainLogoAnimation.setAnimationListener(this);
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
}
# 1 楼答案
只需将文本放在单独的文本视图中,并自行设置动画即可