2016-08-08 10 views
0

私はAndroidの完全な初心者です。主なアクティビティをどのようにフェードインできますか?基本的に私はアプリを開いた後、画面を黒くしてからイメージをフェードインします。私はこの2時間の間にこれをやろうとしており、解決策を見つけることができません。フェードイン主なアクティビティ

これは私のコードです:

package com.example.radu.gladiators2; 

import android.os.Bundle; 
import android.support.annotation.Nullable; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 
import android.view.WindowManager; 
import android.view.animation.Animation; 
import android.view.animation.AnimationUtils; 
import android.widget.ImageView; 

/** 
* Created by Radu on 8/8/2016. 
*/ 

public class Splash extends AppCompatActivity { 

@Override 
protected void onCreate(@Nullable Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splash_screen); 
} 

@Override 
public void onWindowFocusChanged(boolean hasFocus) { 
    super.onWindowFocusChanged(hasFocus); 
    View decorView = getWindow().getDecorView(); 
    if (hasFocus) { 
     decorView.setSystemUiVisibility(
       View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
       | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
       | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 
       | View.SYSTEM_UI_FLAG_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);} 
    } 
} 

そして、これはXMLです:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:src="@drawable/splash_image" 
    android:id="@+id/imageView" 
    android:scaleType="centerCrop" /> 

+0

を.com/questions/18475826 /フェードインアニメーションオンアクティビティ遷移 – ono

+0

私はそれを私の問題に適応させようとしましたが、主な活動では機能していないようです。 – Radu

答えて

0

このお試しください:// stackoverflowの:ここでの例はhttpだ

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layoutAnimation="@android.R.anim.fade_in" > 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:src="@drawable/splash_image" 
    android:id="@+id/imageView" 
    android:scaleType="centerCrop" /> 
+0

動作しません。私にいくつかの厄介なエラーを与えます – Radu

+0

エラーを表示できますか? – X09

関連する問題