项目需求讨论 — 待机界面

2,112 阅读2分钟

一天,产品经理走过来搭了下我的肩膀。
产品经理:我要我们的APP有一个酷炫的待机界面。
我:可以啊,你要怎么样的界面?
产品经理:我也不知道啊,要么像手机店里面那种展览的手机知道不,不是经常有个待机界面,那种颜色不停变化的那种,我们也搞个这种,然后就五彩斑斓的黑色,记住哦。弄好给我看看效果
我:产品经理666,mmp,产品经理一个需求就够我玩一年....

反正我不是读书人

我走到美工那里,准备甩锅,
我:产品经理要五彩斑斓的黑色,反正我也不知道,别问我具体东西,你看着办吧。
美工:XXXXXXXXXXXXX。

最后美工给了我一组颜色值:

然后说她的任务完成了。也不管了。又把锅扔给我。

最后打算用我所标识的1-2-3的顺序来做。

(PS:转成gif后变的很模糊很奇怪了.....)

根据美工给的色值,我们可以先做四个界面:

color_first.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#81FFEF"
        android:endColor="#F067B4"
        android:angle="0"/>
</shape>

color_second.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#F6D242"
        android:endColor="#FF52E5"
        android:angle="135"/>
</shape>

color_third.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#FFA8A8"
        android:endColor="#FCFF00"
        android:angle="135"/>
</shape>

color_firth.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#81FFEF"
        android:endColor="#FFA8A8"
        android:angle="135"/>
</shape>

我们四个界面都做好了。我们把它们四个放在一起: color_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <item
        android:drawable="@drawable/color_first"
        android:duration="3000" />
    <item
        android:drawable="@drawable/color_second"
        android:duration="3000" />
    <item
        android:drawable="@drawable/color_third"
        android:duration="3000" />

    <item
        android:drawable="@drawable/color_firth"
        android:duration="3000" />

</animation-list>

activity_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_splash"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/color_list"
    android:orientation="vertical">

</LinearLayout>

Activity.java:

public class SplashActivity extends Activity {
    AnimationDrawable anim;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        
        LinearLayout container = (LinearLayout) findViewById(R.id.ll_splash);
        anim = (AnimationDrawable) container.getBackground();
        anim.setEnterFadeDuration(2000);
        anim.setExitFadeDuration(1000);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (anim != null && !anim.isRunning())
            anim.start();
    }
    
    @Override
    protected void onPause() {
        super.onPause();
        if (anim != null && anim.isRunning())
            anim.stop();
    }
}