android - 在 kenburnsview 启动画面中添加另一个 textview

标签 android animation splash-screen android-kenburnsview

我想在我的应用程序名称下方添加另一个 TextView ,这是启动

private void setAnimation() {
    ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(findViewById(R.id.welcome_text), "scaleX", 5.0F, 1.0F);
    scaleXAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleXAnimation.setDuration(1200);
    ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(findViewById(R.id.welcome_text), "scaleY", 5.0F, 1.0F);
    scaleYAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleYAnimation.setDuration(1200);
    ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(findViewById(R.id.welcome_text), "alpha", 0.0F, 1.0F);
    alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    alphaAnimation.setDuration(1200);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(scaleXAnimation).with(scaleYAnimation).with(alphaAnimation);
    animatorSet.setStartDelay(500);
    animatorSet.start();

    findViewById(R.id.imagelogo).setAlpha(1.0F);
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.translate_top_to_center);
    findViewById(R.id.imagelogo).startAnimation(anim);
}

我试图复制代码并放置它

scaleXAnimation = ObjectAnimator.ofFloat(findViewById(R.id.smslogan_text), "scaleX", 5.0F, 1.0F);
    scaleXAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleXAnimation.setDuration(1200);
    scaleYAnimation = ObjectAnimator.ofFloat(findViewById(R.id.smslogan_text), "scaleY", 5.0F, 1.0F);
    scaleYAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleYAnimation.setDuration(1200);
    alphaAnimation = ObjectAnimator.ofFloat(findViewById(R.id.smslogan_text), "alpha", 0.0F, 1.0F);
    alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    alphaAnimation.setDuration(1200);
    animatorSet = new AnimatorSet();
    animatorSet.play(scaleXAnimation).with(scaleYAnimation).with(alphaAnimation);
    animatorSet.setStartDelay(500);
    animatorSet.start();

但是第二个textview出现在第一个TextView的顶部

enter image description here

这是我的 activity_splash.xml 代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <eventnotif.sti.com.broadcastreceiver.KenBurnsView
        android:id="@+id/ken_burns_images"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ImageView
        android:id="@+id/imagelogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="106dp"
        android:src="@drawable/smlogo" />

    <eventnotif.sti.com.broadcastreceiver.RobotoTextView
        android:id="@+id/welcome_text"
        style="@style/TextViewAppearance.Headline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imagelogo"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:alpha="0.0"
        android:text="@string/app_name"
        android:textColor="@color/global_color_primary_light" />
    <eventnotif.sti.com.broadcastreceiver.RobotoTextView
        android:id="@+id/smslogan_text"
        style="@style/TextViewAppearance.Headline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imagelogo"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:alpha="0.0"
        android:text="@string/slogan"
        android:textColor="@color/global_color_primary_light" />
</RelativeLayout>

最佳答案

尝试在标题二中这样更改

 <eventnotif.sti.com.broadcastreceiver.RobotoTextView
        android:id="@+id/smslogan_text"
        style="@style/TextViewAppearance.Headline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        <!--Set below welcome text-->

        android:layout_below="@+id/welcome_text"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:alpha="0.0"
        android:text="@string/slogan"
        android:textColor="@color/global_color_primary_light" />

关于android - 在 kenburnsview 启动画面中添加另一个 textview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39761521/

相关文章:

android - 手动执行 Intent 并获得结果

android - PDFBox:将高清图像写入 PDF

java - 删除房间内数据库

android - 两个按钮的动画交换位置

c#.net 启动画面加载

java - 使用java在android中的文本和整数之间迭代以显示专业的启动画面

android - 如何检查应用程序是否已在android中关闭?

graphics - 树可视化和动画

ios - Wpf 动画——就像 iOS 上的摇动图标

android - 如何在 android 中将 imageview 的不透明度从透明度 0% 设置为 100%?