Home Creating a splash screen that does not take extra time for the app to start
Reply: 0

Creating a splash screen that does not take extra time for the app to start

user3729
1#
user3729 Published in May 27, 2018, 3:31 am

I have this splash screen:

The problem with it is that it gets an extra time for the app to start which is something I do not really want. I found that there is a way of changing the default white splash screen that shows when you start any app using android:windowBackground. At the moment I am doing it with layer-list but I am facing quite big problems converting LinearLayout to layer-list. Any idea how to make this code?

Current splash screen code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_background"
android:orientation="vertical"
android:weightSum="100"
tools:context="com.example.kristiqngergov.healthapp.SplashActivity">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="23">
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="34"
    android:gravity="center|bottom">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/splash_logo"
        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.286" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="43"
    android:gravity="center"
    android:orientation="vertical">
        <TextView
            android:id="@+id/app"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_gravity="center"
            android:layout_marginBottom="10dp"
            android:fontFamily="sans-serif-black"
            android:lineSpacingExtra="9sp"
            android:textColor="#fff"
            android:textSize="53sp"
            android:textStyle="normal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            tools:layout_editor_absoluteY="448dp"
            tools:text="Dr.Oh" />

        <TextView
            android:id="@+id/wait"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="12sp"
            android:fontFamily="sans-serif"
            android:textStyle="normal"
            android:textColor="#fff"
            android:layout_centerVertical="true"
            tools:text="Моля изчакайте..." />
</LinearLayout>

The splash code I want:

   <?xml version="1.0" encoding="utf-8"?>
  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:drawable="@drawable/gradient_background" />
      <item>
         <bitmap android:src="@drawable/splash_logo" />
      </item>
 </layer-list>

The problem with the layer list is that I can not really set the weight of every item which is a big problem since the image is way too big and it fit the whole screen.

Layer-list splash screen:

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307845 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO