Chipkat
Chipkat

Reputation: 43

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?

Upvotes: 4

Views: 7626

Answers (2)

Manoj Sah
Manoj Sah

Reputation: 1

<ImageView
    android:id="@+id/splashscreen"
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:src="@drawable/study"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/splashtext"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="188dp"
    android:fontFamily="@font/dancing_script"
    android:gravity="center"
    android:text="Lets Prepare Your NEC \nLicense Examination"
    android:textColor="#00235B"
    android:textSize="25dp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.547"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/splashscreen"
    app:layout_constraintVertical_bias="0.0" />

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyle"
    android:layout_width="35dp"
    android:layout_height="32dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.496"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/splashtext"
    app:layout_constraintVertical_bias="0.189" />

Upvotes: 0

Viktor Peovski
Viktor Peovski

Reputation: 26

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>

Upvotes: 1

Related Questions