Home Forum
Welcome, Guest
Username Password: Remember me

A better splash screen
(1 viewing) (1) Guest
Discussion related to creating Android software
  • Page:
  • 1

TOPIC: A better splash screen

A better splash screen 2 years, 9 months ago #183

I have an app with a View which fills the display at 320x480. I made a
splash image which is smaller, 200x200, and the logic to display this
is ok. It doesn't have the effect I'd like though, which is to show
the splash first, centered, and without clearing the background which
at present it is doing by setting to black. Ideally I'd like the
existing background to become dimmed, as it is when Android Dialogs
are shown, but I definitely would like to avoid the black border.
Here is my attempt at fixing this in the apps layout/main.xml file:
<?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:id="@+id/splashscreen"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/splash"
android:layout_gravity="center"/>
</LinearLayout>

Thanks!
  • ticktock
  • OFFLINE
  • Professor
  • Posts: 79
  • Karma: 6
Last Edit: 2 years, 9 months ago by ticktock.

Re:A better splash screen 2 years, 9 months ago #184

Think this is almost there, it displays an image in the centre of the screen and dims whatever is underneath.

The only thing that is not dimmed is the notification bar, not sure if this is right or wrong, looks bad but as the notification bar is still active it may be for the best, otherwise you can position the activity window over the title bar, this will disable and dim the notification bar.

Here is the layout
<?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:id="@+id/splashscreen" android:scaleType="centerInside"
android:adjustViewBounds="true" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:src="@drawable/splash"
android:layout_gravity="center" android:background="#AA222222" />
</LinearLayout>


All I have done to this is to add the android:backgound and change the layout width and height to fill parent, this is to give the dim effect, remove the background to leave the background fully transparent, #AA222222 is pure guesswork by the way, not sure what the standard value used for dimming is or if it has a resource.

The key change was to apply a theme to the activity showing the splash view add

android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"


to the splash screen activity or application element in the manifest.

There are a few variations on the theme to be found here developer.android.com/reference/android/R.style.html.

device.png
Attachments:
  • mmoore
  • OFFLINE
  • Examiner
  • Posts: 22
  • Karma: 1
Last Edit: 2 years, 9 months ago by mmoore.

Re:A better splash screen 2 years, 9 months ago #185

Yup!
Thanks, that was it ... cool!
Now onto animations in the splash - probably not that hard, as you are really only dealing with Views the same approach will work.
  • ticktock
  • OFFLINE
  • Professor
  • Posts: 79
  • Karma: 6
  • Page:
  • 1
Time to create page: 0.37 seconds
Copyright © 2012 Android Academy. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.
 
Glossary
We have 22 guests online