Android Splash Ekran Açılış ekranı Ortalma

splash_layout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    android:id="@+id/FrameLayout01"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/arkaplan"
    android:layout_gravity="center">

    <ImageView
        android:id="@+id/ImageView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/splash1"
        android:minHeight="100px"
        android:minWidth="100px"
        android:layout_gravity="center" >

    </ImageView>
</FrameLayout>



Splash Java Class

package tr.com.caglayangrup.caritakip.caritakip;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SplashScreen extends AppCompatActivity {
    private static int SPLASH_TIME_OUT = 3000;

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

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent1 = new Intent(SplashScreen.this,MainActivity.class);
                startActivity(intent1);
                finish();
            }
        },SPLASH_TIME_OUT);
    }
}


Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="tr.com.caglayangrup.caritakip.caritakip">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@style/Theme.AppCompat.NoActionBar">

        </activity>
        <activity android:name=".SplashScreen"
            android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Hiç yorum yok:

Yorum Gönder