Create a fullscreem and untitled splash

Asked

Viewed 525 times

1

Hi, I’m initiating on Android Studio, and I’m having a question.

How to make my splash stay with the image in full screen and without the title bar?

My image PNG has 750 x 1334.

Follows my code:

MANIFESTS: Androidmanifests.xml

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

    <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=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".MainActivity"></activity>
    </application>

</manifest>

JAVA: Splashactivity

package br.com.site;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(getBaseContext(), MainActivity.class));
                finish();
            }
        }, 5000);


    }
}

LAYOUT: activity_splash.html

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".SplashActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:src="@drawable/splash" />

</LinearLayout>

1 answer

1


Add in the manifest where Splashscreen is the following theme:

 android:theme="@style/Theme.AppCompat.NoActionBar"

will look like this:

   <activity android:name=".SplashActivity"
             android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Edit 1:

in the added imageview Xml: scaleType and adjustViewBounds, leaving width in match_parent and height in wrap_content, as follows:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:adjustViewBounds="true"  
    android:layout_gravity="center"
    android:src="@drawable/splash" />

In this way the image will occupy the whole width and the height will be proportional to the size of the image.

If you want the image to occupy the entire area regardless of proportionality, leave:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    android:layout_gravity="center"
    android:src="@drawable/splash" />
  • Hello Murillo, thanks for the help. The title came out, but the image is not yet full. The image is not filling the total width of the app. What I need to do?

  • 1

    @James, I edited my answer, I believe that now the problem will be solved.

  • Thank you Murilo, I’m starting on Android and had not found anything that would help me to do this...rsrs, thank you very much.

  • 1

    Quiet, it is possible to do this also by java, but I find it more practical by xml rs

  • Thank you very much.

  • Can you help me with that? https://answall.com/questions/383075/executar-html5-dentro-do-webview-android

  • With you in parts @Tiago, I need to test only how to receive the event click by html, I already answer there.

  • Ahhh, I’m using Webview on android, and accessing the test URL. Let’s talk on the other page of the code to get better. https://answall.com/questions/383136/salvar-imagem-assinada-dentro-do-servidor

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.