UI freezes on removing white screen before splash - android

I am trying to remove white screen before splash so i followed solutions mentioned in these links
How To fix white screen on app Start up?
White screen before splashscreen
I tried almost every solution mentioned here
which includes changing activity theme to this
android:theme="#android:style/Theme.Translucent.NoTitleBar"
or adding this to my theme
<item name="android:windowDisablePreview">true</item>
but implementing any of this freezes the UI for a while on click of the App icon after that everything works fine as desired.
Has anyone succeeded to fix this lag. Any help will be appreciated.

create a custom theme like,
//splashTheme
//create in styles
<style name="splashTheme" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and then apply the theme as follows,
//manifest file
<activity
android:name=".SplashActivity"
android:theme="#style/AppTheme.splashTheme"
android:windowSoftInputMode="adjustResize|stateHidden" />
try this.

following changes work for me on mac:
1.Goto android studio preferences.
2.In Build,Execution and Deployment select "Instant run".
3.disable-Enable instant run to hot swap code/resource changes on deploy.
4.apply changes,clean project and rebuild again.

Finally got my answer Splash Screen in Right Way. I do just following.
In values-->styles.xml I created splash screen background image
<style name="Splash" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
</style>
For below api 19, in values-19->styles.xml I used
<style name="Splash" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
I removed setContentview() from SplashActivity and added style for splash screen in Manifest.xml file android:theme="#style/Splash"

Related

Android app masthead display

I have created an app using Android Studio 2.3.3, choosing Empty Activity Template. After its creation I went and changed the background color to something like colorAccent and I also changed the colorPrimary to colorAccent in colors.xml.
Now, when I ran the app, following emulator display appeared.
As you can see, it displays my app name, followed by a dark line.
I don't understand where this dark line has come from and how can I get rid of this?
However, this dark line does not appear in Android Studio design mode (see screenshot below).
it is shadow of action bar my friend
to remove this shadow add below lines to your theme under res/values/style
<style name="MYTheme" parent="android:Theme.Holo.Light">
<item name="colorPrimary">#color/colorWhite</item>
<item name="colorPrimaryDark">#color/colorWhite</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
</style>
now add this in manifest file this to your activity
<activity
android:name=".YourActivity"
android:theme="#style/MYTheme"/>
or try this
getSupportActionBar().setElevation(0);

Spalsh Screen shows battery status on top

I want to hide the top bar from splash screens 1:[First image] 2:[Second Image] as you can see these are two splash screens sample and i want to hide the upper bar which shows battery status and other things on image2,which is also shown in my app
Add this line of code in your Manifest file under the Splashscreen activity.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
When u use AppCompat you have to include below line of code in your style to get the FullScreen.
<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>

Styling FacebookActivity to avoid terrible progress bar

I just implemented logging in through Facebook using their SDK in conjunction with ParseFacebookUtilsV4.
In my manifest I had to declare a FacebookActivity that gets launched when I try to sign in, and that works great.
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
This snippet comes from official docs so I didn't choose anything. What I found really weird is its styling. On my emulator (API 22) it has a ProgressBar that seems to be coming from the '90s! Is there a way to style it? I have tried changing the android:theme attribute, but with no success.
I thought of extending com.facebook.FacebookActivity, but after digging through source code I found out it inflates a com.facebook.LoginFragment, which is then responsible of the progress bar actually. Any ideas?
You can now set theme in your AndroidManifest.xml
commit src link
Usage:
AndroidManifest.xml
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ApplicationName" android:value="#string/app_name"/>
<meta-data android:name="com.facebook.sdk.WebDialogTheme" android:value="#style/Theme.AppCompat.Light.NoActionBar"/>
This is valid for facebook-android-sdk v4.8.0+
First of all it's not progress bar, it's progress dialog. I don't know how make custom progress dialog with style.
So here is a solution changing default style(Theme_Translucent_NoTitleBar) with holo style(Theme.Holo.Light). For that we need to make changes in Facebook SDk.
1) Put below code in style.xml
<style name="NewDialogTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">#android:color/transparent</item>
</style>
2) And second thing that we need to change here in WebDialog.java inside com.facebook.widget package.
public static final int DEFAULT_THEME = R.style.NewDialogTheme;
Hope this helps you.
Only one method works for me:
FacebookSdk.setWebDialogTheme(android.R.style.Theme_Holo_Light_NoActionBar);
immediately after FacebookSdk.sdkInitialize
The android:theme you have set to your activity in your manifest is based on the original themes that were used in Android before Honeycomb. That's why your ProgressBar looks so old. You could try another theme like:
#android:style/Theme.Material.NoActionBar.TranslucentDecor
This is based on the new Material Design but of course this only works on Lollipop devices. Look into the AppCompat-Library for more Material Design styles that are compatible with older devices.
You can style whatever you want like this:
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:textViewStyle">#style/MyStyles.TextView</item>
<item name="android:buttonStyle">#style/MyStyles.Button</item>
<item name="android:progressBarStyle">#style/MyStyle.ProgressStyle</item>
<item name="android:indeterminateProgressStyle">#style/MyStyle.ProgressStyle</item>
<item name="android:actionBarStyle">#style/MyStyle.Toolbar</item>
</style>
Then
<style name="MyStyle.ProgressStyle" parent="android:Widget.Holo.Light.ProgressBar">
<item name="...">...</item>
</style>
When an Activity creates the View for a Dialog, it goes to the Activity's theme and looks up the theme specified by the android:alertDialogTheme attribute.
What you need to do is set that attribute to AppCompat's dialog theme (which for <v21 defaults to Theme.Holo):
In the theme that you apply to the Facebook Activity:
<style name="MyFacebookTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
...
<item name="android:alertDialogTheme">#style/Theme.AppCompat.Light.Dialog</item>
...
</style>

Why there is a white screen appears for 1sec when starting to run the apps in Android?

When I click the app icons and start to run the apps, it will appear a white screen for 1 sec.
I don't know why.
Is there any idea to clear this white screen and directly go to my activity?
The white/black screen is the window background image.
The window background is shown while e.g. your onCreate() runs and your layouts are being inflated. It can take some time especially if there's a lot of bitmaps that need to be read, decoded and scaled.
Changing the theme works because some themes have a non-default window background. For example, Theme.Wallpaper has a transparent background. There are other definitions there, too. Essentially what you want is:
<style name="YourTheme">
<item name="android:windowBackground">#null</item>
</style>
Programmatically you can achieve the same with
getWindow().setBackgroundDrawable(null);
at the top of activity onCreate().
(Old question but got bumped up by another answer and there wasn't a good answer.)
Settings. File>Settings>Build,Deployment>Instant Run Deselect all options shown there.
and add below line in your style.xml
<item name="android:windowDisablePreview">true</item>
<style name="AppTheme" parent="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>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDisablePreview">true</item>
</style>
apply changes in AndroidMainfest.xml
<application
android:theme="#style/AppTheme">
After I change style.xml:
<resources>
<style name="AppTheme" parent="android:Theme.Wallpaper" />
</resources>
it works!!
Thanks all
Add the following in the manifest file of the corresponding activity
android:launchMode="standard"
and remove android:label="#string/app_name" from the corresponding activity ,this actually helped me
In your manifest.xml file remove the line android:theme="#style/AppTheme" for your app. and check it again
Use this tag in your manifest:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
In Styles add the following things
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
Hope this will help you and its working for me

Transparent Activity does not open with typical animation, just appears?

I have a transparent activity defined using this theme:
<style name="Theme.Transparent.NoDim" parent="android:Theme.Translucent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
And in the AndroidManifest.xml
<activity android:name=".Activity"
android:theme="#style/Theme.Transparent.NoDim">
</activity>
However since adding this theme to the Activity, when opened the Activity does not open using the normal animation (where the view expands to fill the screen), rather it just suddenly appears.
Any ideas on why, and a fix?
Thank you!

Categories

Resources