javaandroidxmlsplash-screen

Include text on the splash screen Android


I am using this popular method from this site to make a splash screen: Splash Screens the Right Way.

And I want to display a translated text "loading" to different languages. This was asked earlier in the comments section, and the author replied, but I do not know how to do what he says. Here is what he replied: https://www.bignerdranch.com/blog/splash-screens-the-right-way/#comment-2633426495

How can i draw the text on the screen? (If it's posible) Or as it says there, How to "include" it in the drawable?

Is another method preferable?


Solution

  • Here is my splash activity xml
    This is an easy solution and places the text bellow the image.
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="@color/colorIcons"
    tools:context=".SplashActivity">
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerVertical="true"
        android:gravity="center"
        android:orientation="vertical">
    
        <ImageView
            android:id="@+id/splashImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:gravity="center_horizontal"
            android:scaleType="fitCenter"
            android:src="@mipmap/ic_launcher">
        </ImageView>
    
        <TextView
            android:id="@+id/splashText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/app_name"
            android:textColor="@color/colorPrimary_text"
            android:textSize="36sp" />
    </LinearLayout>