Splash Screen Not Working in Android 4.4.4

Hi I try to create a splash screen but it’s not working and also the login screen isn’t working!! I test it in android 4.4.4

1.MainActivity.class

`

public class MainActivity extends AppCompatActivity {
        /** Duration of wait **/
        private final int SPLASH_TIME_OUT = 5000;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
           new Handler().postDelayed(new Runnable(){
                @Override
                public void run() {
                    Intent startLoginActivity = new Intent(MainActivity.this, login.class);
                    startActivity(startLoginActivity);
                    finish();
                }
            }, SPLASH_TIME_OUT);

        }
    }

`

1-1 activity_main.xml the ImageView + No Errors In The Code!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/todo" />
</LinearLayout>

2.login.class : This Activity Not Working (White Screen)

`

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="78dp"
        android:layout_marginLeft="78dp"
        android:layout_marginTop="429dp"
        android:layout_marginEnd="120dp"
        android:layout_marginRight="120dp"
        android:layout_marginBottom="257dp"
        android:ems="10"
        android:hint="@string/uname"
        android:importantForAutofill="no"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.596"
         />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="78dp"
        android:layout_marginLeft="78dp"
        android:layout_marginTop="502dp"
        android:layout_marginEnd="120dp"
        android:layout_marginRight="120dp"
        android:layout_marginBottom="184dp"
        android:ems="10"
        android:hint="@string/upass"
        android:importantForAutofill="no"
        android:inputType="textPassword"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.676"/>

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="43dp"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="163dp"
        android:layout_marginLeft="163dp"
        android:layout_marginTop="189dp"
        android:layout_marginEnd="205dp"
        android:layout_marginRight="205dp"
        android:layout_marginBottom="495dp"
        app:srcCompat="@drawable/circle" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="168dp"
        android:layout_marginLeft="168dp"
        android:layout_marginTop="368dp"
        android:layout_marginEnd="208dp"
        android:layout_marginRight="208dp"
        android:layout_marginBottom="344dp"
        android:text="@string/login"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/angry_btn"

        android:layout_width="186dp"
        android:layout_height="57dp"
        android:layout_alignParentStart="true"

        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="90dp"
        android:layout_marginLeft="90dp"
        android:layout_marginTop="589dp"
        android:layout_marginEnd="136dp"
        android:layout_marginRight="136dp"
        android:layout_marginBottom="85dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A8A8"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="0"
        android:text="@string/login"
        android:textColor="#FFFFFF"
        android:textSize="23sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.389"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.813" />
</RelativeLayout>

`

3.AndroidManifest:

`

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".login">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

`

3.Gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.ribat.batchcommand18"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
}

this is my first question in stackoverflow 🙂

Answer

You should check login activity’s xml layout.

login activity’s widgets have improper properties.

For example bottom’s Login Button

<Button
    android:id="@+id/angry_btn"

    android:layout_width="186dp"
    android:layout_height="57dp"
    android:layout_alignParentStart="true"

    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="90dp"
    android:layout_marginLeft="90dp"
    android:layout_marginTop="589dp"
    android:layout_marginEnd="136dp"
    android:layout_marginRight="136dp"
    android:layout_marginBottom="85dp"
    android:background="@drawable/buttonshape"
    android:shadowColor="#A8A8A8"
    android:shadowDx="0"
    android:shadowDy="0"
    android:shadowRadius="0"
    android:text="@string/login"
    android:textColor="#FFFFFF"
    android:textSize="23sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.389"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.813" />
  • layout_margin is too large for small screen devices.
  • In this case layout_alignParent not necessary.
  • app:layout_constraint is ConstraintLayout properties, not RelativeLayout.

Try to like this and motify other widgets.

<Button
    android:id="@+id/angry_btn"
    android:layout_width="186dp"
    android:layout_height="57dp"
    android:background="#ffff00"
    android:shadowColor="#A8A8A8"
    android:shadowDx="0"
    android:shadowDy="0"
    android:shadowRadius="0"
    android:text="@string/login"
    android:textColor="#FFFFFF"
    android:textSize="23sp"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="85dp"
    />

Leave a Reply

Your email address will not be published. Required fields are marked *