在 Android 启动屏幕上包含文本

问题描述 投票:0回答:2

我正在使用该网站上的这种流行方法来制作启动屏幕: 启动画面的正确方式

我想显示翻译后的文本“正在加载”到不同的语言。之前在评论区问过这个问题,作者回复了,但我不知道该怎么做。以下是他的回复:https://www.bignerdranch.com/blog/splash-screens-the-right-way/#comment-2633426495

如何在屏幕上绘制文字? (如果可能的话)或者正如它所说,如何将它“包含”在可绘制对象中?

还有其他方法更好吗?

java android xml splash-screen
2个回答
1
投票
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>


0
投票
<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" />
© www.soinside.com 2019 - 2024. All rights reserved.