首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我想在我的片段上加载动画屏幕,就像闪屏一样

我想在我的片段上加载动画屏幕,就像闪屏一样
EN

Stack Overflow用户
提问于 2018-09-14 02:44:53
回答 1查看 347关注 0票数 1

我想在我的应用程序上加载动画,但我的应用程序主要是片段,这是我的代码,请帮助我,因为在我想要它的用户看到的第一件事是动画后,它消失了一段时间

代码语言:javascript
复制
    public class MainActivity extends AppCompatActivity implements MainFragment.OnFragmentInteractionListener,ParrablesFragment.OnParFragmentInteractionListener,TortoiseFragment.OnTorFragmentInteractionListener,AeroFragment.OnaeroFragmentInteractionListener,ValueFragment.OnvalFragmentInteractionListener,SecreteFragment.OnSecreteFragmentInteractionListener,
        UglyFragment.OnUglyFragmentInteractionListener,ThreeFragment.OnThreeFragmentInteractionListener,PrincessFragment.OnPrincesFragmentInteractionListener,WiseFragment.OnWiseFragmentInteractionListener
        ,BadFragment.OnBadFragmentInteractionListener,BullyFragment.OnBullyFragmentInteractionListener,RashFragment.OnRashFragmentInteractionListener,SucessFragment.OnSucessFragmentInteractionListener,Page2Fragment.OnPage2FragmentInteractionListener,NewPageFragment.OnNewPFragmentInteractionListener
,Chapter2Fragment.OnChapterFragmentInteractionListener,LV1Fragment.OnLv1FragmentInteractionListener,LV2Fragment.OnLV2FragmentInteractionListener,LV3Fragment.OnLV3FragmentInteractionListener,LV4Fragment.OnLV4FragmentInteractionListener,LV5Fragment.OnLV5FragmentInteractionListener,LV6Fragment.OnLV6FragmentInteractionListener
,LV7Fragment.OnLV7FragmentInteractionListener,LV8Fragment.OnLV8FragmentInteractionListener,LV9Fragment.OnLV9FragmentInteractionListener,LV10Fragment.OnLV10FragmentInteractionListener,LV11Fragment.OnLv11FragmentInteractionListener,Lv12Fragment.OnLV12FragmentInteractionListener,LV13Fragment.OnLv13FragmentInteractionListener
,LV14Fragment.OnLV14FragmentInteractionListener,LV15Fragment.OnLV15FragmentInteractionListener,LV16Fragment.OnLV16FragmentInteractionListener,LV17Fragment.OnLV17FragmentInteractionListener,LV18Fragment.OnLV18FragmentInteractionListener,LV19Fragment.OnLV19FragmentInteractionListener,LV20Fragment.OnLV20FragmentInteractionListener
,LV21Fragment.OnLV21FragmentInteractionListener,LV22Fragment.OnLV23FragmentInteractionListener,LV23Fragment.OnLV22FragmentInteractionListener,AdventureFragment.OnADVENTUREFragmentInteractionListener,AV1Fragment.OnAV1FragmentInteractionListener,AV2Fragment.OnAV2FragmentInteractionListener,AV3Fragment.OnAV3FragmentInteractionListener
,AV4Fragment.OnAV4FragmentInteractionListener,AV5Fragment.OnAV5FragmentInteractionListener,AV6Fragment.OnAV6FragmentInteractionListener,AV7Fragment.OnAV7FragmentInteractionListener,AV8Fragment.OnAV8FragmentInteractionListener,AV9Fragment.OnAV9FragmentInteractionListener,AV1OFragment.OnAV10FragmentInteractionListener
,AV11Fragment.OnAV11FragmentInteractionListener,AV12Fragment.OnAV12FragmentInteractionListener,AV13Fragment.OnAV13FragmentInteractionListener,AV14Fragment.OnAV14FragmentInteractionListener,AV15Fragment.OnAV15FragmentInteractionListener,AV16Fragment.OnAV16FragmentInteractionListener,AV17Fragment.OnAV17FragmentInteractionListener
,AV18Fragment.OnAV18FragmentInteractionListener,AV19Fragment.OnAV19FragmentInteractionListener,AV20Fragment.OnAV20FragmentInteractionListener,AV21Fragment.OnAV21FragmentInteractionListener,AV22Fragment.OnAV22FragmentInteractionListener,Av23Fragment.OnAV23FragmentInteractionListener,AV24Fragment.OnAV24FragmentInteractionListener
,MysteryFragment.OnMysteryFragmentInteractionListener,MY1Fragment.OnMy1FragmentInteractionListener,M2Fragment.OnM2FragmentInteractionListener,M3Fragment.OnM3FragmentInteractionListener,M4Fragment.OnM4FragmentInteractionListener,M5Fragment.OnM5FragmentInteractionListener,M6Fragment.OnM6FragmentInteractionListener,M7Fragment.OnM7FragmentInteractionListener
,M9Fragment.OnM9FragmentInteractionListener,M8Fragment.OnM8FragmentInteractionListener,M10Fragment.OnM10FragmentInteractionListener,M11Fragment.OnM11FragmentInteractionListener,M12Fragment.OnM12FragmentInteractionListener,M13Fragment.OnM13FragmentInteractionListener,M14Fragment.OnM14FragmentInteractionListener
,M15Fragment.OnM15FragmentInteractionListener,M16Fragment.OnM16FragmentInteractionListener,M17Fragment.OnM17FragmentInteractionListener,M18Fragment.OnM18FragmentInteractionListener,M19Fragment.OnM19FragmentInteractionListener,M20Fragment.OnM20FragmentInteractionListener,M21Fragment.OnM21FragmentInteractionListener
,M22Fragment.OnM22FragmentInteractionListener,M23Fragment.OnM23FragmentInteractionListener,M24Fragment.OnM24FragmentInteractionListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
        android.support.v4.app.Fragment fragment = manager.findFragmentById(R.id.fragment_container);

        if (fragment == null) {
            fragment = new MainFragment();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.fragment_container, fragment);
            transaction.commit();


        }
    }
EN

回答 1

Stack Overflow用户

发布于 2018-09-14 07:20:11

使用以下代码创建初始屏幕:

在res > drawable文件夹中,添加一个标题为splash.xml的新的可绘制资源文件

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/colorPrimary"/>

<item>
    <bitmap android:src="@drawable/logo"
        android:gravity="center"/>
</item>
</layer-list>

在values > styles.xml中,粘贴以下内容:

代码语言:javascript
复制
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
</style>

然后创建一个java类SplashActivity.java

代码语言:javascript
复制
package com.example.android.motouch3;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    finish();
}
}

现在,当用户打开应用程序时,带有徽标的闪屏将弹出几秒钟,然后恢复到正常屏幕。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52320007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档