Android How Do Yo Ushow Welcome Screen Again
Welcome
An piece of cake to use and customizable welcome screen for Android apps.
Look in the sample to see how the above welcome screen is created.
Features
- Fully customizable
- RTL support
- Power to apply built in layouts or custom fragments
- Built in layouts support all screen sizes and orientations
Please open a new issue if you detect a problems or have a problem.
Javadoc
Changelog/Releases
Major Changes in 1.0.0
If you used the library prior to version 1.0, read 1.0.0.physician for details on all breaking changes.
Demo
A demo app is available on Google play:
The source code is in the sample module.
Contributing
Feel complimentary to open a PR to add a characteristic or fix a issues, all contributions are welcome. Please read the contribution notes.
All development takes place on the dev branch.
Tabular array of Contents
- Adding to your project
- Bones Usage
- Extend WelcomeActivity
- Show the welcome screen
- Skipping/Dorsum push behavior
- Included pages
- TitlePage
- BasicPage
- ParallaxPage
- FullscreenParallaxPage
- Custom pages
- Custom Done Push button
- Bottom Layouts
- STANDARD
- STANDARD_DONE_IMAGE
- BUTTON_BAR
- BUTTON_BAR_SINGLE
- INDICATOR_ONLY
- NONE
- Styling
- Themes
- Styles
- Welcome screen keys
- Results
- Animations
- License
Adding to your projection
This library is available through jCenter.
Gradle:
compile 'com.stephentuso:welcome:ane.4.i' If you use proguard, add the following to your proguard rules
-keepclassmembers class * extends com.stephentuso.welcome.WelcomeActivity { public static java.lang.String welcomeKey(); } Basic Usage
Extend WelcomeActivity
To create a welcome screen, add a form to your projection that extends WelcomeActivity and add information technology to AndroidManifest:
<activeness android : proper noun= ".MyWelcomeActivity" android : theme= "@style/WelcomeScreenTheme" />
The theme must be a kid theme of WelcomeScreenTheme
Override the Activity's configuration() method. Employ WelcomeConfiguration.Builder to fix it up:
@Override protected WelcomeConfiguration configuration() { return new WelcomeConfiguration.Builder(this) .defaultBackgroundColor(R .color.background) .folio(new TitlePage(R .drawable.logo, "Title" ) ) .page(new BasicPage(R .drawable.paradigm, "Header" , "More text." ) .background(R .color.red_background) ) .page(new BasicPage(R .drawable.epitome, "Lorem ipsum" , "dolor sit amet." ) ) .swipeToDismiss(true) .build(); } You do not need to override onCreate or telephone call setContentView.
Notation: For now, defaultBackgroundColor() needs to be called before adding pages.
Show the welcome screen
Welcome screens are started with WelcomeHelper. onSaveInstanceState is needed to be sure but one instance of the welcome screen is started. Add together the following to the Activity you want to show the welcome screen before (probably your launcher activeness):
WelcomeHelper welcomeScreen; @Override protected void onCreate(Packet savedInstanceState) { ... welcomeScreen = new WelcomeHelper(this, MyWelcomeActivity .class); welcomeScreen.show(savedInstanceState); ... } @Override protected void onSaveInstanceState(Bundle outState) { super .onSaveInstanceState(outState); welcomeScreen.onSaveInstanceState(outState); } If you lot have issues with the buttons/indicator beingness covered past the nav bar, use one of the .SolidNavigation welcome screen themes.
To force the welcome screen to be shown, for case, to let the user view information technology again when a button is pressed, create a WelcomeHelper every bit shown to a higher place and telephone call .forceShow().
Skipping/Dorsum push button behavior
Past default, the welcome screen can be skipped, and pressing the back button volition navigate to the previous page or close (skip) the welcome screen if on the start page. This tin be inverse with Architect.canSkip(), backButtonSkips() (only applies if canSkip is true), and backButtonNavigatesPages(). If you disable skipping, the welcome screen will non be stored as completed when it closes.
If you lot desire to require users to navigate through the welcome screen before using the app, call canSkip(false) and close your app if the welcome screen's result is RESULT_CANCELED.
See Results below for how to reply if a welcome screen is canceled.
Included pages
The classes listed below are subclasses of WelcomePage and can be used with the page method of WelcomeConfiguration.Builder
TitlePage
A page with an image and a title. A parallax effect tin be practical to the image.
Constructor:
TitlePage(@DrawableRes int drawableResId, String title) BasicPage
A folio with an paradigm, heading, and clarification. A parallax effect can exist applied to the image.
Constructor:
BasicPage(@DrawableRes int drawableResId, String title, Cord description) ParallaxPage
Similar to the basic folio, but instead of an image y'all can supply a layout that will have a parallax event applied to it. The speed at which the layout's children motility is determined past their position in the layout, the first will motility the slowest and the concluding will move the fastest.
Constructor:
ParallaxPage(@LayoutRes int layoutResId, String title, String clarification) FullscreenParallaxPage
Applies a parallax result in the same way the normal parallax folio does, but the layout y'all provide fills the whole fragment, and at that place isn't a header or description.
Constructor:
FullscreenParallaxPage(@LayoutRes int layoutResId) Custom pages
You tin can add your own fragments to the welcome screen with FragmentWelcomePage:
@Override protected WelcomeConfiguration configuration() { return new WelcomeConfiguration.Builder(this) ... .page(new FragmentWelcomePage() { @Override protected Fragment fragment() { return new ExampleFragment(); } }.groundwork(R .color.red_background)) ... } See animations beneath for adding animations to custom fragments.
Custom Done Push
If you desire to use a push in a custom fragment instead of the default done button, telephone call useCustomDoneButton(true) on the builder and new WelcomeFinisher(MyFragment.this).finish() in the button'southward OnClickListener.
Bottom Layouts
The layout shown below the pages can exist changed with the bottomLayout Builder method, which uses the WelcomeConfiguration.BottomLayout enum. The possible values are explained below.
STANDARD
The default layout, can have skip/previous buttons, the current folio indicator, and next/done buttons.
STANDARD_DONE_IMAGE
Same as STANDARD, merely the done button is an ImageButton rather than a Button. Uses a check mark as the prototype by default (that can be changed with styles).
BUTTON_BAR
Has two buttons side past side at the bottom with the current folio indicator in a higher place them. By default the text is "Log In" and "Sign Up", just can be changed with styles. In your WelcomeActivity subclass, override onButtonBarFirstPressed and onButtonBarSecondPressed to handle clicks. More documentation volition be added later, see ButtonBarWelcomeActivity in the sample for an case.
BUTTON_BAR_SINGLE
Same as BUTTON_BAR, merely with merely one push (uses onButtonBarFirstPressed for clicks).
INDICATOR_ONLY
Just the current page indicator, no buttons.
NONE
No layout; no buttons, no indicator
Styling
Themes
The provided themes are listed below.
Transparent status/navigation on API 19+. Content does non flow under status bar:
-
WelcomeSceenTheme- The default theme. For utilise with dark backgrounds; the text, indicator, and buttons are light colored. -
WelcomeScreenTheme.Lite- For use with light backgrounds; the text, indicator, and buttons are nighttime colored.
Transparent status bar, solid navigation bar on API 19+. Content does not menstruation under status bar:
-
WelcomeScreenTheme.SolidNavigation -
WelcomeScreenTheme.Light.SolidNavigation
Transparent status bar, solid navigation bar on API xix+. Content flows under status bar:
-
WelcomeScreenTheme.SolidNavigation.UnderStatusBar -
WelcomeScreenTheme.Low-cal.SolidNavigation.UnderStatusBar
Styles
Typefaces and a few other things (animations, push visibility) have to be set with WelcomeConfiguration.Builder, but everything else that is customizable tin can be inverse with styles.
Y'all can add styles as shown below. Optional items are in foursquare brackets.
<fashion proper name= "CustomWelcomeScreenTheme" parent= "Encounter THEMES ABOVE" > <!---- TEXT STYLES ----> <!-- Colour of push button text and titles/headings (in built in fragments) By default, this is also the color of the done/next button --> <particular name= "android:textColorPrimary" >color</detail> <!-- Color of other text By default, this is used for the skip button text colour --> <item name= "android:textColorSecondary" >color</particular> <!-- Descriptions/other text --> <detail name= "welcomeNormalTextStyle" >@style/MyNormalText</item> <!-- Headings --> <item proper name= "welcomeLargeTextStyle" >@mode/MyLargeText</item> <!-- Titles --> <item proper noun= "welcomeTitleTextStyle" >@style/MyTitleText</detail> <!---- Button STYLES ----> <!-- Background is applied to all buttons, to alter a specific button background use the individual button styles --> <item name= "welcomeButtonBackground" >drawable</item> <!-- Done/skip button text --> <item name= "welcomeButtonSkipText" >string</item> <item proper noun= "welcomeButtonDoneText" >cord</detail> <!-- Button styles for STANDARD and STANDARD_DONE_IMAGE --> <item name= "welcomeButtonSkipStyle" >@style/MyButtonSkip</item> <item proper name= "welcomeButtonNextStyle" >@style/MyButtonNext</item> <item name= "welcomeButtonDoneStyle" >@style/MyButtonDone</item> <!-- Button styles for BUTTON_BAR --> <item name= "welcomeButtonBarFirstStyle" >@style/MyButtonFirst</item> <detail name= "welcomeButtonBarSecondStyle" >@style/MyButtonSecond</particular> <!---- OTHER STYLES ----> <!-- Current page indicator --> <particular proper name= "welcomeIndicatorStyle" >@style/MyWelcomeIndicator</item> <!-- Divider between lesser layout and pages --> <item name= "welcomeDividerStyle" >@manner/MyWelcomeScreenDivider</particular> <!-- The drawable or color to fade to if swipeToDismiss is enabled --> <item name= "android:windowBackground" >drawable|color</item> <!-- Add the following if y'all want to show the action bar. Use Builder.showActionBarBackButton(true) to show the back button. --> <item name= "windowActionBar" >truthful</item> <item name= "windowNoTitle" >fake</item> </style> <style name= "MyWelcomeIndicator" parent= "WelcomeScreenPageIndicator[.Light]" > <item name= "indicatorColor" >colour</item> <item proper noun= "currentPageColor" >color</detail> <item name= "animation" >fade|slide|none</detail> </style> <!-- Employ this to change the next button's image/color To support RTL, add this in values-ldrtl/styles with an image facing left --> <fashion name= "MyButtonNext" parent= "WelcomeScreenButton.Next" > <item name= "android:src" >drawable</item> <item proper noun= "android:tint" >color</item> </style> <manner name= "MyButtonSkip" parent= "WelcomeScreenButton.Skip" > <detail name= "android:textColor" >color</item> </style> <mode name= "MyButtonDone" parent= "WelcomeScreenButton.Done" > <!-- If using BottomLayuout.STANDARD --> <item name= "android:textColor" >color</particular> <!-- If using BottomLayout.STANDARD_DONE_IMAGE --> <particular proper noun= "android:tint" >colour</detail> <item name= "android:src" >drawable</item> </style> <!-- A divider that is directly in a higher place the buttons/indicator. The background color is transparent by default --> <style name= "MyWelcomeScreenDivider" parent= "WelcomeScreenDivider[.Nighttime|.Lite]" > <item name= "android:groundwork" >drawable|color</item> <item proper noun= "android:layout_height" >dimen</item> </style> <!-- The following can apply to whatever of the three text styles --> <mode name= "MyText" parent= "WelcomeScreenText[.Big|.Title][.Centered]" > <!-- Add whatsoever properties that can be practical to a TextView --> </style>
Welcome screen keys
If you lot want to use multiple welcome screens (in different parts of your app) or have updated one and want to show it once again, y'all can assign keys (Brand sure they are unique!) to welcome screens by adding the following to your welcome screen Activity.
public static Cord welcomeKey() { return "Your unique key" ; } Annotation: Only change this to a new value if you want everyone who has already used your app to see the welcome screen again! This primal is used to determine whether or not to show the welcome screen.
Results
You can mind for the consequence of a welcome screen in the Activity that started it by overriding onActivityResult:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super .onActivityResult(requestCode, resultCode, information); if (requestCode == WelcomeHelper .DEFAULT_WELCOME_SCREEN_REQUEST) { // The fundamental of the welcome screen is in the Intent Cord welcomeKey = data.getStringExtra(WelcomeActivity .WELCOME_SCREEN_KEY); if (resultCode == RESULT_OK) { // Lawmaking here will run if the welcome screen was completed } else { // Code here will run if the welcome screen was canceled // In nearly cases you'll want to call finish() here } } } One use for this is making certain users see the whole welcome screen before using your app - disable skipping so close your main activity when the welcome screen is canceled.
Animations
Animations that play as pages are scrolled can be added to your custom fragments by implementing WelcomePage.OnChangeListener. As an instance, a fade effect is shown below.
@Override public void onScrolled(int pageIndex, bladder first, int offsetPixels) { if (Build .VERSION.SDK_INT >= 11 && imageView != null) { imageView.setAlpha(1 - Math .abs(offset)); } } To add parallax effects similar to the included parallax folio, apply WelcomeUtils.applyParallaxEffect() in onScrolled. For example:
@Override public void onScrolled(int pageIndex, float kickoff, int offsetPixels) { if (parallaxLayout != zip) WelcomeUtils .applyParallaxEffect(parallaxLayout, false, offsetPixels, 0.3f, 0.2f); } License
Copyright 2015-2017 Stephen Tuso Licensed nether the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required past applicable law or agreed to in writing, software distributed under the License is distributed on an "Equally IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF Any KIND, either limited or implied. See the License for the specific language governing permissions and limitations under the License. lemmonsoplamaidn1956.blogspot.com
Source: https://github.com/stephentuso/welcome-android
0 Response to "Android How Do Yo Ushow Welcome Screen Again"
Post a Comment