I have the code as below in my Android app.
My res/values/styles.xml:
<style name="FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
res/drawable/background_splash.xml:
<item
android:drawable="#color/colorPrimaryDark"/>
<item>
<bitmap
android:gravity="center"
android:src="#mipmap/image1"/>
</item>
AndroidManifest.xml:
<activity
android:name=".SplashActivity"
android:theme="#style/FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
SplashActivity.java:
public class SplashActivity extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 5000;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
finish();
}
}, SPLASH_TIME_OUT);
}
}
I have the image1 with appropriate resolution/size present in the res folder. But the splash screen does not display the image covering full screen but displays with reduced size only some part of the screen. Can you please advice what needs to be done. I went through some of the suggestions present on some sites but it did not help.
In your res/drawable/background_splash.xml, change android:gravity
you can use fill, in my case I used top|fill_horizontal for horizontal fill only, choose the combination you want.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/White"/>
<item>
<bitmap
android:gravity="top|fill_horizontal"
android:src="#drawable/splash"/>
</item>
</layer-list>
use parent of theme
parent="#style/Theme.AppCompat.Light.NoTitleBar.Fullscreen"
code for activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="#color/colorAccent"
tools:context=".SplashActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</android.support.constraint.ConstraintLayout>
Code for Splash.java
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);
getSupportActionBar().hide();
setContentView(R.layout.activity_splash);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashActivity.this,MainActivity.class);
startActivity(i);
finish();
}
},2000);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/image" />
</LinearLayout
And use
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
in your Activity code.
Make sure your splash xml file has no padding of any sort. If any, delete.
Related
I followed Microsoft tutorial on how to make a splash screen in xamarin.android, and it works properly. Now I would like to insert a progress ring under the bitmap. I've tried different approaches but i can't seem to find the right way to do it
This is the splash screen code:
splash_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/splash_background"/>
</item>
<item android:left="20dp">
<bitmap
android:src="#mipmap/coronamap_bianco"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
splash style in resources > values > styles.xml
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
<item name="android:statusBarColor">#304057</item>
</style>
SplashActivity.cs
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
Finish();
}
}
EDIT
Since the constraint layer didn't work, I tried to simplify it using a linear layout. As output I get a white screen.
SplashActivity.cs
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
SetContentView(Resource.Layout.SplashLayout);
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
Finish();
}
}
SplashLayout.xml
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/iv_splash_screeen"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/coronamap_bianco" />
<ProgressBar
android:id="#+id/progress_bar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp" />
</LinearLayout>
Output: splash screen
You can create a layout for the splash screen , in that layout create an image and a loading circle
splash_screen.xml activity code
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/iv_splash_screeen"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.45"
app:srcCompat="#drawable/my_logo" />
<ProgressBar
android:id="#+id/progress_bar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/iv_splash_screeen" />
</androidx.constraintlayout.widget.ConstraintLayout>
In your activity, OnCreate set that layout
SplashActivity.cs
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.splash_screen);
}
.....
...
}
Output:
Based on the official sample , we can create a .xaml layout for SplashActivity. Then can achieve that .
Splashlayout.xaml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_gravity="center"
android:background="#drawable/splash_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ProgressBar
android:id="#+id/progressBar1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Used in SplashActivity :
//public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
//{
// base.OnCreate(savedInstanceState, persistentState);
// Log.Debug(TAG, "SplashActivity.OnCreate");
//}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Splashlayout);
}
Here not forgettingn to modify in style.xml :
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<!--<item name="android:windowBackground">#drawable/splash_screen</item>-->
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
Then effect as follow :
Here is the modified sample link for reference .
I am making UI in android studio.And problem occurs when my app switches between activities. Actually i put timer to switch from one activity to other of 3 second .When 3 second of time complete ,my app crashes insted of going into navigationdrawer activity(which is part of project).
And it shows the error in logcat
(navigationdrawer.java.18)
which becomes setSupportActionBar(toolbar); error in java file
setSupportActionBar cannot be applied to android.support.v7.widget.Toolbar
I have tried to find solution on different sites but could not find any solution.
Navigationdrawer.java
package com.example.zeeshan.myapplication;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
public class Navigationdrawer extends AppCompatActivity {
private DrawerLayout drawer;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigationdrawer);
Toolbar toolbar=findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawer=findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle=new ActionBarDrawerToggle(this,drawer,toolbar,R.string.navigation_drawer_open,R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
}
#Override
public void onBackPressed() {
if(drawer.isDrawerOpen(GravityCompat.START)){
drawer.closeDrawer(GravityCompat.START);
}
else {
super.onBackPressed();
}
}
}
Navigationdrawer.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Navigationdrawer"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_menu" />
</android.support.v4.widget.DrawerLayout>
Home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="190dp"
android:text="Welcome to Wheat yield Estimation App..."
android:textColor="#color/white"
android:textSize="35dp"
android:layout_marginTop="240dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:textStyle="italic"/>
</RelativeLayout>
Home.java
package com.example.zeeshan.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
Timer timer;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
timer=new Timer();
timer.schedule(new TimerTask() {
#Override
public void run() {
Intent intent=new Intent(MainActivity.this,navigationdrawer.class);
startActivity(intent);
}
},3000);
}
}
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
I was expecting that app will switch between activities but it does not and crashes ..
In your MainActivity timer you have the following code:
Intent intent=new Intent(MainActivity.this,Login.class);
You are going to this activity (Login) instead of the navigationdrawer activity you actually want to go to. Change the above code to:
Intent intent=new Intent(MainActivity.this,Navigationdrawer.class);
Unless ofcourse if you have a Login activity and from that activity you end up in the NavigationDrawer activity, in which case please include the code and xml of that activity as well.
You are most likely just missing the below from your AndroidManifest:
<activity
android:name=".Navigationdrawer"
android:label="#string/app_name" />
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".Navigationdrawer"
android:label="#string/app_name"
/>
I have a default activity with just a button
<Button
android:id="#+id/openActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:text="Click to open activity" />
and a function that opens a new activity:
public void openActivity(){
final Button openActivity = (Button) findViewById(R.id.openActivity);
openActivity.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
MainActivity.this.startActivity(new Intent(MainActivity.this, SecondActivity.class));
}
});
}
For the second activity I have just a TextView with a custom message:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="#a56699"
tools:context="com.example.tge_00.myapplication.SecondActivity">
<TextView
android:id="#+id/textViewTextToChange"
android:layout_width="121dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="120dp"
android:text="Second Activity" />
</android.support.constraint.ConstraintLayout>
that is supposed to be displayed on top of the main activity, smaller than the screens size:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.widthPixels;
getWindow().setLayout((int)(width*.8), (int)(height*0.6));
}
public boolean onTouchEvent(MotionEvent event){
this.finish();
return true;
}
But the problem is that the activity from behind should still be visible in the portions where the second activity doesn't cover the screen but those portions are black and I don't know why.
I'm new in Android programming so please be gentle :)
just use this theme in your activity.
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="colorAccent">#color/White</item>
</style>
i want to change only one menu item in the action bar. I tried to change the same icon color instead of making it transparent into the desired color but the edges show the background of the action bar.
Here is my action bar what it looks like:
https://www.dropbox.com/s/1sjnk975dnj17kr/before.png?dl=0
And here is the goal i want to reach:
https://www.dropbox.com/s/ul7hh2gxtfox1pk/goal.png?dl=0
Here are my xml files:
menu_main.xml
<item
android:id= "#+id/location"
android:icon="#drawable/ic_room_white_48dp"
android:title=""
android:orderInCategory="2"
app:showAsAction="always"/>
<item
android:id= "#+id/report"
android:icon="#drawable/report"
android:title=""
android:orderInCategory="3"
app:showAsAction="always"/>
<item
android:id= "#+id/message"
android:icon="#drawable/ic_comment_white_48dp"
android:title=""
android:orderInCategory="4"
app:showAsAction="always"/>
styles.xml
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#B9ACC1</item>
<item name="colorPrimaryDark">#827689</item>
<item name="colorAccent">#827689</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="#android:style/Widget.Holo.Light.ActionButton">
<item name="android:padding">15dip</item>
</style>
UPDATE1 :
Adding a way to avoid xml and code duplication.
UPDATE2 :
Adding static listener.
I don't know if you can achieve your goal just by changing your menu.xml but the Toolbar is a viewGroup so you can achieve your goal with a view.xml which should looks like it :
toolbar.xml :
<LinearLayout
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_marginRight="8dp"
android:background="#000000">
<Button
android:id="#+id/button_first"
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:background="#android:drawable/ic_lock_idle_lock" />
</LinearLayout>
<LinearLayout
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_marginRight="8dp"
android:background="#000000">
<Button
android:id="#+id/button_second"
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:background="#android:drawable/ic_lock_idle_lock" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
It can be boring to add this code on all of your xml so i advice you to to use thé <include /> attribute like this :
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"/>
</RelativeLayout>
Then, you just have to set the Toolbar and use the Button
MainActivity.java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button buttonFirst = (Button) findViewById(R.id.button_first);
final Button buttonSecond = (Button) findViewById(R.id.button_second);
buttonFirst.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
buttonSecond.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
}
If all of your button have the same listener, you can make them static into avoid the code duplication :
IconListener.java :
public class IconListener {
public static View.OnClickListener listenerButtonOne = new View.OnClickListener() {
#Override
public void onClick(View v) {
//DO what you want
}
};
public static View.OnClickListener listenerButtonTwo = new View.OnClickListener() {
#Override
public void onClick(View v) {
//Do what you want
}
};
}
So your MainActivity.java became
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button buttonFirst = (Button) findViewById(R.id.button_first);
final Button buttonSecond = (Button) findViewById(R.id.button_second);
buttonFirst.setOnClickListener(IconListener.listenerButtonOne)
buttonSecond.setOnClickListener(IconListener.listenerButtonTwo);
}
I want to make a splash screen in my application, for that i need to know how to show an image in full screen. This could me made by XML or Java code ? And how?
For now i just made this:
public class SplashScreen extends Activity {
private static final int STOPSPLASH = 0;
private static final long SPLASHTIME = 5000;
private Handler splashHandler = new Handler() {
#Override
public void handleMessage(Message msg) {
switch (msg.what) {
case STOPSPLASH:
//remove SplashScreen from view
Intent intent = new Intent(SplashScreen.this, jetpack.class);
startActivity(intent);
break;
}
super.handleMessage(msg);
}
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Message msg = new Message();
msg.what = STOPSPLASH;
splashHandler.sendMessageDelayed(msg, SPLASHTIME);
}
}
How can be this splash_screen.xml ?
Thank you for your help.
The best way to show a full screen splash activity is by putting this line in your manifest under activity tag
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen"
You can use other themes as well
Theme.Black.NoTitleBar.Fullscreen
Theme.NoTitleBar.Fullscreen
<activity
android:name="com.example.SplashActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
For Latest Api Lollipop and above
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
Define this theme for the splash activity and provide it in manifest
android:theme="#style/Theme.AppCompat.Light.NoActionBar.FullScreen"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/image" />
</LinearLayout>
and add the below code before setContentView(R.layout.splash_screen);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
If R.layout.splash_screen included an image with height and width set to fill_parent or match_parent (depending on version). It will fill the screen
<style name="FullScreen" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
just using super.onCreate and setConntentView
code :
/** Hiding Title bar of this activity screen */
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
/** Making this activity, full screen */
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);